Abstract class vs Interface java

preview_player
Показать описание
Abstract classes vs Interfaces in java

A simple example that demonstrates the use of both Abstract Classes and Interfaces. The two can be used in many different ways, either exclusively or in combination. We chose to keep them separate in order to demonstrate the main differences.

Multiple inheritance is not allowed in java and a class can only extend one parent

class. Interfaces provide a form of multiple inheritance. Interfaces are not classes,

however an interface can extend more than one parent interface.

Interfaces provide a form of multiple inheritance. A class can extend only one other class.

Interfaces are limited to public methods and constants with no implementation.

The abstract keyword is used to declare abstract class.

The interface keyword is used to declare interface.

Abstract class achieves partial abstraction (0 to 100%) whereas interface achieves fully abstraction (100%).

Java dərsləri
Рекомендации по теме