Java extends vs implements
Jul 19, 2021
Object-Oriented Programming languageoffers different features like encapsulation, inheritance, polymorphism, etc. As Java isan OOP, it supports the concept of inheritance. The two keywords extends and implements are used to achieve inheritance in the Java program. There are somedifferences between extends and implements.
Java extends keyword
- In Java, inheritance allows a child class to use the methods and variables of already declared base class. It reduces the rewriting of code.
- Inheritance is implemented using extends keyword.
- The data members declared inside the super class are accessible to the child class depending on the access specifier used.
- Any class in Java can only inherit one super class.
- For example, class ArrayList extends AbstractList class. And AbstractList extends AbstractCollection class.