Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 1.2 KB

README.md

File metadata and controls

16 lines (12 loc) · 1.2 KB

AbstractClassesAndInterfaces

Some examples that show how Abstract Classes and Interfaces work in Java. I learned this on Edureka.

What is an Abstract Class?

An abstract class is a class that is declared abstract —it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.

What is an Interface?

An interface is a reference type in Java. It is similar to class. It is a collection of abstract methods. A class implements an interface (or extends another class), thereby inheriting the abstract methods of the interface. image

Interfaces can only extend other interfaces. image

But what is difference between abstract class and interface?

The Abstract class and Interface both are used to have abstraction. An abstract class contains an abstract keyword on the declaration whereas an Interface is a sketch that is used to implement a class. image