
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Difference Between extends and implements keywords in Java
In this post, we will understand the differences between ‘Extends’ and ‘Implements’ keyword.
Extends
Using this, a class can be used as a base class, and another class inherits this base class.
An interface can also inherit other interfaces using this keyword.
Only one superclass can be extended by a class.
Any number of interfaces can be extended by an interface.
It is not required for the subclass (that extends a superclass) to override all the methods in the superclass.
Following is an example of the extends keyword −
Example
class Super { ..... ..... } class Sub extends Super { ..... ..... }
Implements
This keyword helps a class to implement an interface.
A class can implement any number of interfaces at a point in time.
It is required for a class (that implements an interface) to implement all the methods of that specific interface.
It can never be used implement any other interface.
Following is an example of the implements keyword
Example
public interface Animal { } public class Mammal implements Animal { } public class Dog extends Mammal { }
- Related Articles
- What is the difference between keywords and reserved words in Java?
- What is the difference between super and this, keywords in Java?
- What is the difference between throw and throws keywords in Java?
- Explain the difference between const and readonly keywords in C#
- The extends Keyword in Java
- What is the difference between keywords const and readonly in C#?
- What is the difference between VAR and DYNAMIC keywords in C#?
- Keywords in Java
- What is the difference between public, static and void keywords in C#?
- Can Enum implements an interface in Java?\n
- Are ‘this’ and ‘super’ keywords in Java?
- Are true and false keywords in java?
- Agricultural Implements and Tools
- List the Interfaces That a Class Implements in Java
- List the Interfaces that an Interface Extends in Java
