What is the difference between an abstract class and an interface in Java?
73
18-Jul-2024
Ravi Vishwakarma
18-Jul-2024Abstract Class
An abstract class is a class that cannot be instantiated on its own and may contain abstract methods (methods without a body) and non-abstract methods (methods with a body).
Example
Interface
An interface is a reference type in Java that is used to specify a set of abstract methods that a class must implement. From Java 8 onwards, interfaces can also contain default and static methods with implementations.
Example
Key Differences
Read more
When to use Interface?
What's the difference between an Abstract Class and an Interface in Java?
What is the purpose of an interface in OOP?