Question 27Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

Which of the following demonstrates the implementation of inheritance in Java?

  1. Aclass B inherits A {}
  2. Bclass A contains B {}
  3. Cclass A implements B {}
  4. Dclass A extends B {}
Show answerHide answer

Correct answer: (D) class A extends B {}

Explanation

Java uses the keyword extends for class inheritance, e.g. class A extends B. implements is used when a class implements an interface; inherits and contains are not Java keywords.

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

This is question 27 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 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.