0 votes
in JAVA by
What are the differences between abstract class and interface?

1 Answer

0 votes
by

Below are the differences between abstract class and interface:

Abstract Class:

An abstract class can have a method body (non-abstract methods).

An abstract class can have instance variables.

An abstract class can have the constructor.

An abstract class can have static methods.

You can extend one abstract class.

The abstract class can provide the implementation of the interface.

The abstract keyword is used to declare an abstract class.

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

An abstract class can be extended using keyword extends

A Java abstract class can have class members like private, protected, etc.

Java Interface:

You can implement multiple interfaces.

The interface cannot have static methods.

The interface cannot have the constructor.

An interface cannot have instance variables.

The interface has only abstract methods.

An interface class can be implemented using keyword implements

An interface can extend another Java interface only.

The interface keyword is used to declare an interface.

The Interface can't provide the implementation of the abstract class.

Members of a Java interface are public by default.

Related questions

0 votes
asked Jan 24, 2021 in JAVA by rajeshsharma
+1 vote
asked Jun 16, 2019 in JAVA by reins.robin
...