Inheritance

Q1: Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B?

A While creating the object firstly the constructor of class B will be called followed by constructor of class A.

B While creating the object firstly the constructor of class A will be called followed by constructor of class B.

C The constructor of only class B will be called.

D The constructor of only class A will be called.

E The order of calling constructors depends upon whether constructors in class A and class B are private or public.

ANS:B - While creating the object firstly the constructor of class A will be called followed by constructor of class B.

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.