Question
Download Solution PDFWhich of the statement are CORRECT?
(A) Constructors are invoked automatically when the objects are created.
(B) Constructors do not have return types, not even void and therefore they cannot return values.
(C) Constructors cannot be inherited though a derived class can call the base class constructors.
(D) Constructors can be declared as virtual.
Choose the correct answer from the options given below:
Answer (Detailed Solution Below)
Detailed Solution
Download Solution PDFThe correct answer is (A), (B) and (C) Only
EXPLANATION:
- (A) Constructors are invoked automatically when the objects are created - Correct.
- In object-oriented programming, a constructor is a special method that is automatically called when an object is created. Its purpose is to initialize the new object's attributes.
- (B) Constructors do not have return types, not even void and therefore they cannot return values - Correct.
- Constructors are primarily used to initialize object attributes. They do not return values, and specifying a return type for them can lead to compiler errors.
- (C) Constructors cannot be inherited though a derived class can call the base class constructors - Correct.
-
An object of a subclass type will automatically call its superclass's constructor as part of its creation process, but the constructor itself isn't an inheritable part of the superclass.
-
- (D) Constructors can be declared as virtual - Incorrect.
- Virtuality applies to functions that you want to be executed polymorphically, where the specific implementation depends on the actual run-time type of the object.
- Constructors don't work this way: when you create an object of a derived class, it's the derived constructor that you want to run.
- The base class constructor is called automatically already, before the derived class constructor, so there is no need for virtuality.
Last updated on Jun 6, 2025
-> The UGC NET Exam Schedule 2025 for June has been released on its official website.
-> The UGC NET Application Correction Window 2025 is available from 14th May to 15th May 2025.
-> The UGC NET 2025 online application form submission closed on 12th May 2025.
-> The June 2025 Exam will be conducted from 21st June to 30th June 2025
-> The UGC-NET exam takes place for 85 subjects, to determine the eligibility for 'Junior Research Fellowship’ and ‘Assistant Professor’ posts, as well as for PhD. admissions.
-> The exam is conducted bi-annually - in June and December cycles.
-> The exam comprises two papers - Paper I and Paper II. Paper I consists of 50 questions and Paper II consists of 100 questions.
-> The candidates who are preparing for the exam can check the UGC NET Previous Year Papers and UGC NET Test Series to boost their preparations.