Question 161Asked in DSSSB TGT Computer Science, 25 Jun 2023, Shift 3 (4:30 PM)

What is the main purpose of inheritance in object-oriented programming?

  1. AOverriding methods
  2. BAll of the given options
  3. CData hiding
  4. DCode reusability
Show answerHide answer

Correct answer: (D) Code reusability

Explanation

Inheritance lets a subclass reuse the fields and methods of an existing class, so its main purpose is code reusability.

From DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 3 (4:30 PM)

This is question 161 of DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 3 (4:30 PM). 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.