1.

A class has its default constructor defined as public. Class B inherits class A privately. The class ___________(a) B will not be able to have instances(b) Only A can have instances(c) Only B can have instances(d) Both classes can have instancesThe question was posed to me in an interview.The question is from Public Access Specifier topic in chapter Access Specifiers of Object Oriented Programming

Answer»

Correct answer is (d) Both classes can have INSTANCES

The best EXPLANATION: CLASS A can have instances as it has public DEFAULT constructor. Class will have its own constructors defined. HENCE both classes can have instances.



Discussion

No Comment Found

Related InterviewSolutions