Which keyword is used by a Java class to inherit from another class?

2024

Which keyword is used by a Java class to inherit from another class?

Answer: A. extendsConceptIn Java, class-to-class inheritance creates a subclass–superclass relationship. A subclass declaration names its direct superclass with the keyword…

  1. A.

    extends

  2. B.

    inherits

  3. C.

    implements

  4. D.

    More than one of the above

  5. E.

    None of the above

Attempted by 721 students.

Show answer & explanation

Correct answer: A

Concept

In Java, class-to-class inheritance creates a subclass–superclass relationship.

A subclass declaration names its direct superclass with the keyword extends.

Application

  1. For example, class Child extends Parent {} declares Child as a subclass of Parent.

  2. Child can inherit the accessible fields and methods of Parent.

Contrast and cross-check

  • implements connects a class to one or more interfaces; it does not name a superclass.

  • inherits is an English verb used to describe inheritance, not Java declaration syntax.

  • The set choices “More than one of the above” and “None of the above” do not apply because one listed keyword has the specified class-to-class role.

Therefore, the required keyword is extends.

Explore the full course: Rssb Senior Computer Instructor

Loading lesson…