Font Awesome Icons

Tutorial

Difference between Abstract class and Interface in Java

Both the abstract class and interface are used for abstraction but there are some differences between them. We will discuss them in a tabular form.

 

 

Abstract class

Interface

An abstract class can have default method implementation.

Interfaces provide pure abstraction & can not have implementation at all.

It may contain non-final variables.

Variables declared in an interface are by default final.

An abstract class can be extended using the keyword “extends.

The interface should be implemented using the keyword “ïmplements”

Can have public, protected, private and default modifier.

Interface methods are by default public. you can not use any other access modifier with it.

It can extend only one abstract class

Can implement multiple interfaces

An abstract class can have constructors

An interface can not have constructors

An abstract class can extend another class and can implement multiple Java interfaces

The interface can extend another Java interface only

Hi, Welcome to etechvidya