1.

If class A inherits class B and class C as “class A: public class B, public class C {// class body ;}; ”, which class constructor will be called first?(a) Class A(b) Class B(c) Class C(d) All togetherI had been asked this question in an international level competition.I'd like to ask this question from Multiple Inheritance in chapter Inheritance & its Types of Object Oriented Programming

Answer»

The correct OPTION is (B) CLASS B

Best explanation: The constructors of parent class will be called first. In that, the constructor of the classes will be called in the same sequence as that mentioned in class definition inheritance. Since class B is mentioned first for inheritance, its constructor will be called first.



Discussion

No Comment Found

Related InterviewSolutions