What keyword is used in Java to indicate that class C inherits from class B?

Study for the Computer Science EOPA Exam. Access multiple choice questions, each with hints and explanations. Boost your preparation!

In Java, the keyword used to indicate that one class inherits from another is "extends." This keyword establishes an inheritance relationship between the two classes, where the subclass (the class that extends) gains access to the attributes and methods of the superclass (the class being extended).

For instance, if class C extends class B, it means that class C inherits all the fields and methods from class B, allowing for code reusability and the ability to override methods to modify or customize their behavior. This mechanism is fundamental to object-oriented programming in Java, enabling polymorphism and hierarchical class structures.

The other keywords in the options serve different purposes. "Implements" is used when a class is adopting an interface, while "inherits" and "subclass" are not actual keywords in Java, although they describe the concept of inheritance and subclasses, respectively.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy