Question 113Asked in BPSC TRE 1.0 (2023) Computer Science Class 11-12

Which is correct syntax of inheritance?

  1. Aclass base_classname : access derived_classname {/*define class body*/};
  2. Bclass derived_classname : access base_classname {/*define class body*/};
  3. Cclass derived_classname : base_classname {/*define class body*/};
  4. DMore than one of the above
  5. 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

This is question 113 of BPSC TRE 1.0 (2023) Computer Science Class 11-12 — Previous Year Paper. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.