Question 113Asked in BPSC TRE 1.0 (2023) Computer Science Class 11-12
Which is correct syntax of inheritance?
Aclass base_classname : access derived_classname {/*define class body*/};
Bclass derived_classname : access base_classname {/*define class body*/};
Cclass derived_classname : base_classname {/*define class body*/};
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (D) More than one of the above
Explanation
Both (B) and (C) are valid: class derived : access base { }; and, without an access specifier, class derived : base { }; where the default is private for classes.
From BPSC TRE 1.0 (2023) Computer Science Class 11-12 — Previous Year Paper