All Exams Test series for 1 year @ ₹349 only
Question

Which of the following is not true about constructor

The correct answer is
They can be virtual.

This question asks to identify the statement that is NOT true about constructors in programming, likely C++.

Constructor Properties Analysis

Let's analyze each statement regarding constructors:

  • Statement 1: "When an object is created and initialized at the same time, a copy constructor gets called."

    This statement is generally true. Copy constructors are invoked when a new object is initialized from an existing object of the same type, often during object creation or function calls passing objects by value.

  • Statement 2: "They do not have return types, not even void."

    This statement is true. Constructors are special member functions that do not return any value and cannot be declared with a return type, including $void$.

  • Statement 3: "They can be virtual."

    This statement is false. Constructors cannot be declared as $virtual$. Virtual functions are related to polymorphism and dynamic dispatch, concepts that do not apply to constructors because they are called explicitly during object creation, not through a base class pointer or reference.

  • Statement 4: "They can not be inherited, though a derived class can call the base class constructor."

    This statement is true. Constructors are not inherited by derived classes. However, a derived class constructor is responsible for initializing the base class part of the object, and it does so by explicitly calling the base class constructor.

Conclusion on Constructor Truthfulness

Based on the analysis, the statement "They can be virtual" is the one that is NOT true about constructors.

Was this answer helpful?

Important Questions from OOPs concept

  1. Match List I with List II
    List IList II
    A. OverloadingI. Since function call is resolved during run time, the execution is Slow.
    B. Early bindingII. Since function call is resolved during compilation time, the execution is much faster.
    C. OverridingIII. Supports compile-time polymorphism.
    D. Late BindingIV. Supports run-time polymorphism.

    Choose the correct answer from the options given below:
  2. Which among the following best describes polymorphism ?
  3. Which operator is used for dynamic memory allocation in C++?

  4. Match the LIST-I with LIST-II
    LIST-I (file mode parameters)LIST-II (Meaning)
    A. ios::ateI. Go to end of file on opening
    B. ios::inII. Open fails if the file already exists.
    C. ios::nocreateIII. Open file for reading only
    D. ios::noreplaceIV. Open fails if the file does not exist.
    Choose the correct answer from the options given below:
  5. Which one of the following is correct, when a class grants friend status to another class ?
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App