0 votes
in JAVA by
Using relevant properties highlight the differences between interfaces and abstract classes.

1 Answer

0 votes
by
Availability of methods: Only abstract methods are available in interfaces, whereas non-abstract methods can be present along with abstract methods in abstract classes.

Variable types: Static and final variables can only be declared in case of interfaces, whereas abstract classes can also have non-static and non-final variables.

Inheritance: Multiple inheritance is facilitated by interfaces, whereas abstract classes do not promote multiple inheritances.

Data member accessibility: By default, the class data members of interfaces are of the public- type. Conversely, the class members for an abstract class can be protected or private also.

Implementation: With the help of an abstract class, the implementation of an interface is easily possible. However, the converse is not true;

Abstract class example:

public abstract class Athlete {

public abstract void walk();

}

Interface example:

public interface Walkable {

void walk();

}

Related questions

+1 vote
asked Jan 27, 2020 in JAVA by rahuljain1
0 votes
asked Dec 16, 2020 in JAVA by SakshiSharma
...