Which of the following is not true about constructor: 1 Constructor does not return any value 2 Constructor may be overloaded 3 Constructor needs to be invoked explicitly 4 Constructor is used to initialize data members
Answers
Answered by
0
Answer:
we can overload contructor in derived class
Answered by
0
Answer:
Option 3 - constructor needs to be invoked explicitly is the correct option.
Explanation:
Constructor: A constructor is a block of code that resembles a method. Called when an instance of a class is created.
- Constructor does not return any value: No, they do not return anything. There is no such thing as a return type when declaring a function Object() { [native code] }. A constructor is usually called implicitly when an object is created. It's also not a method because its entire purpose is to set up the instance variables. - This is true.
- Constructor may be overloaded: Overloading constructors works similarly to overloading functions. The name of the overloaded function Object() { [native code] } is the same as the class name, but the number of parameters is different. This is true.
- Constructor needs to be invoked explicitly: There is no need to call constructors directly because they are called automatically when the object is created. This is a false statement.
- Constructor is used to initialising data members: A function Object() { [native code] } is a non-static member function of a class that is used to create objects of the class's type. The member initializer list provides the initializers for direct and virtual bases, as well as non-static data members, in the construction of a class function Object() { [native code] }. This is true.
Hence, the statement "Constructor needs to be invoked explicitly" is the false statement among the given ones.
#SPJ3
Similar questions
Computer Science,
4 months ago
Social Sciences,
4 months ago
Math,
4 months ago
Chemistry,
9 months ago
Math,
9 months ago
Physics,
1 year ago