Abstract class and interface both are utilized to accomplish abstraction
in java. Still, there is part of contrasts between abstract class and
interface which I am partaking in this instructional exercise.
The distinction between Abstract Class and Interface in Java
Abstract Class | Interface |
An abstract class can have both abstract and non-abstract techniques. | The interface can have just abstract strategies. |
An abstract class is broadened utilizing “expands” catchphrase. | The interface is executed utilizing “actualizes” catchphrase. |
Of course, the entrance specifier of strategies is “default”. | Of course, the entrance specifier of strategies is “public”. |
An abstract class can have static, non-static, last and non-last factors. | The interface can have last and static factors. |
The abstract class have a constructor. | The interface doesn’t have a constructor. |
An abstract class is an incomplete execution of abstraction. | The interface is completely the usage of abstraction. |
Different legacy can’t be accomplished by utilizing abstract class. | A different legacy can be accomplished utilizing interface. |
The “abstract” keyword is used to declare an abstract class. An example is given below. abstract MyClass { public abstract void show(); } | “interface” keyword is used to declare an interface. An example is given below. interface MyInterface { void show(); } |
This was about the contrast between abstract class and
interface in java. On the off chance that you discovered anything inaccurate or have questions with respect to
above instructional exercise at that point please notice it.