Why Use Extends Keyword in Java?

Why Use Extends Keyword in Java?

Extends: In Java, the extends keyword is used to indicate that the class which is being defined is derived from the base class using inheritance. So basically, extends keyword is used to extend the functionality of the parent class to the subclass. ... Therefore, a class can extend only one class to avoid ambiguity.

When to use extend and implement in Java?

The keyword extends is used when a class wants to inherit all the properties from another class or an interface that wants to inherit an interface. We use the implements keyword when we want a class to implement an interface.

When to Use implement and extend?

Implements is used for Interfaces and extends is used to extend a class.

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.