What is the difference between interfaces and abstract classes in Java?

Java 8Object Oriented ProgrammingProgramming

Following are the notable differences between interface and abstract class in Java.

Abstract ClassInterface
An abstract class may contain concrete method.
All the methods of an interface are abstract.
To use an abstract class, you need to inherit it. Provide body to (override) the abstract methods if there are any.
To use an interface you need to implement the interface and provide body to (override) all the abstract methods of it.
Members of an abstract class can be public, private, protected or default.
All the members of the interface are public by default.
raja
Published on 10-Jan-2018 16:53:57
Advertisements