Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
interface can contains only set of abstract methods and static constants.where abstract class contains abstract method and concrete methods.
java abstract class can have instance methods that can have a default behaviour andvariables declared in interface are default final
In abstract class have both abstarct and non- abstarct methods.Abstract class don't support multiple inheritance.In abstract class,class name must contain abstract key word.
In interface only have abstarct class.Interface class support multiple inheritance. In interface class,class name must contain interface keyword.
In abstract class , we can achieve zero to hundred percent abstraction, where as in interface we can achieve hundred percent abstraction,
In abstract class , class name must contain abstract key word,
where as in interface class class name must contain interface keyword.
In abstract class we have to write abstract before method to make it abstract, but in interface all the method by default abstract.
abstract is a keyword and when we use abstract with a class then it is called abstract class. if a class decleared as abstract then we can not create object of that class. An abstract class can have abstract and non abstract methods, constructor. An abstract class does not support multiple inheritance. and it may 0% to 100% incomplete.
Where interface is a contract what ideally a class got into and a class is suppose to follow that contract. All the methods in interface by default will be public and abstract (only contain abstract method) and It supports the multiple inheritance. It can contain only static and final variable. and it is 100% incomplete.
1. Methods of java interface are abstract and donot have implementations. Abstarct can have partial implementation and can have abstarct and non abstract methods.
2.Interface only have static and final variables . Abstarct class can have non static, non static, final, non final variables
Methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behaviour. Variables declared in a Java interface is by default final
abstract keyword is used to create abstract class whereas interface is the keyword for interfaces.
Abstract classes can have method implementations whereas interfaces can’t.
A class can extend only one abstract class but it can implement multiple interfaces.
We can run abstract class if it has main() method whereas we can’t run an interface.
An interface is a contract of methods names to be used in inherited classes where as abstract classes have some methods with or without implementation.where intrafes have all methods without implementation.
Abstract class can have abstract and non-abstract and methods.Abstract class doesn't support multiple inheritance.
Interface can have only abstract methods. Interface supports multiple inheritance.Interface has only static and final variables.