Difference between Inheritance and Interface in Java Last Updated : 21 Jun, 2020 Comments Improve Suggest changes Like Article Like Report Java is one of the most popular and widely used programming languages. Java has been one of the most popular programming languages for many years. Java is Object Oriented. However, it is not considered as a pure object-oriented as it provides support for primitive data types (like int, char, etc). In this article, we will understand the difference between the two most important concepts in java, inheritance and interface. Interface: Interfaces are the blueprints of the classes. They specify what a class must do and not how. Like a class, an interface can have methods and variables, but the methods declared in an interface are by default abstract (i.e.) they only contain method signature and not the body of the method. Interfaces are used to implement a complete abstraction. Inheritance: It is a mechanism in java by which one class is allowed to inherit the features of the another class. There are multiple inheritances possible in java. They are: Single Inheritance: In single inheritance, subclasses inherit the features of one superclass. In the image below, class A serves as a base class for the derived class B. Multilevel Inheritance: In Multilevel Inheritance, a derived class will be inheriting a base class and as well as the derived class also act as the base class to other class. In the below image, class A serves as a base class for the derived class B, which in turn serves as a base class for the derived class C. In Java, a class cannot directly access the grandparent’s members. Hierarchical Inheritance: In Hierarchical Inheritance, one class serves as a superclass (base class) for more than one subclass. In the below image, class A serves as a base class for the derived class B, C and D. The following table describes the difference between the inheritance and interface: Category Inheritance Interface Description Inheritance is the mechanism in java by which one class is allowed to inherit the features of another class. Interface is the blueprint of the class. It specifies what a class must do and not how. Like a class, an interface can have methods and variables, but the methods declared in an interface are by default abstract (only method signature, no body). Use It is used to get the features of another class. It is used to provide total abstraction. Syntax class subclass_name extends superclass_name { } interface <interface_name>{ } Number of Inheritance It is used to provide 4 types of inheritance. (multi-level, simple, hybrid and hierarchical inheritance) It is used to provide 1 types of inheritance (multiple). Keywords It uses extends keyword. It uses implements keyword. Inheritance We can inherit lesser classes than Interface if we use Inheritance. We can inherit enormously more classes than Inheritance, if we use Interface. Method Definition Methods can be defined inside the class in case of Inheritance. Methods cannot be defined inside the class in case of Interface (except by using static and default keywords). Overloading It overloads the system if we try to extend a lot of classes. System is not overloaded, no matter how many classes we implement. Functionality Provided It does not provide the functionality of loose coupling It provides the functionality of loose coupling. Multiple Inheritance We cannot do multiple inheritance (causes compile time error). We can do multiple inheritance using interfaces. Comment More infoAdvertise with us Next Article Difference between Inheritance and Interface in Java supriya_saxena Follow Improve Article Tags : Java Computer Subject Difference Between Inheritance java-interfaces +1 More Practice Tags : Java Similar Reads Difference Between Package and Interface in Java In Java, packages and interfaces play crucial roles in organizing and structuring code. They serve different purposes and are used in distinct contexts. In this article, we will learn the concepts of the packages and interfaces in Java. syntax provides examples for each and then presents a table hig 2 min read Difference between Inheritance and Composition in Java When we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class. In doing this, we can reuse the fields and methods of the existing class without having to write them ourself.A subclass inherits all the 3 min read Difference Between Object and Instance in Java The object is an instance of a class. A class is like a blueprint or template that defines the properties and behavior of objects. When we create an object we are creating an instance of that class. Object in JavaThe object is an instance of a class. A class is a blueprint or template that describes 3 min read Interfaces and Inheritance in Java Java supports inheritance and interfaces, which are important concepts for building reusable code. A class can extend another class and can implement one and more than one Java interface. Note: This topic has a major influence on the concept of Java and Multiple Inheritance. Interface Implementation 7 min read Difference Between Abstract Class and Interface in Java In object-oriented programming (OOP), both abstract classes and interfaces serve as fundamental constructs for defining contracts. They establish a blueprint for other classes, ensuring consistent implementation of methods and behaviors. However, they each come with distinct characteristics and use 9 min read Difference between Inheritance and Polymorphism Inheritance is one in which a new class is created that inherits the properties of the already exist class. It supports the concept of code reusability and reduces the length of the code in object-oriented programming. Types of Inheritance are:Single inheritanceMulti-level inheritanceMultiple inheri 5 min read Difference between Final and Abstract in Java In this article, the difference between the abstract class and the final class is discussed. Before getting into the differences, lets first understand what each of this means. Final Class: A class which is declared with the "Final" keyword is known as the final class. The final keyword is used to 4 min read Difference between interfaces and classes in TypeScript In this article, we will see what is the Difference between "interface" and "Classes" in TypeScript. Interface: Interface is the virtual structure that is used for type-checking. In TypeScript we use interface keyword to create the new interface with identity. It create the structure for the same da 3 min read Difference Between Data Hiding and Abstraction in Java Abstraction Is hiding the internal implementation and just highlight the set of services. It is achieved by using the abstract class and interfaces and further implementing the same. Only necessarily characteristics of an object that differentiates it from all other objects. Only the important detai 6 min read How to Implement Multiple Inheritance by Using Interfaces in Java? Multiple Inheritance is a feature of an object-oriented concept, where a class can inherit properties of more than one parent class. The problem occurs when methods with the same signature exist in both the superclasses and subclass. On calling the method, the compiler cannot determine which class m 2 min read Like