1.

Which is the correct syntax of inheritance?(a) class derived_classname : base_classname{ /*define class body*/ };(b) class base_classname : derived_classname{ /*define class body*/ };(c) class derived_classname : access base_classname{ /*define class body*/ };(d) class base_classname :access derived_classname{ /*define class body*/ };I have been asked this question during an interview.I want to ask this question from Inheritance in chapter Inheritance & its Types of Object Oriented Programming

Answer»

Correct choice is (c) class derived_classname : access base_classname{ /*define class body*/ };

The explanation is: Firstly, keyword class should come, followed by the derived class NAME. COLON is MUST followed by access in which BASE class has to be derived, followed by the base class name. And finally the body of class. Semicolon after the body is also must.



Discussion

No Comment Found

Related InterviewSolutions