Abstract Class | Interface |
---|---|
Abstract classes are classes that contain one or more abstract methods. | An Interface is a blueprint of class. |
It can have abstract and non-abstract methods. | It can have only abstract methods. |
It doesn’t support multiple inheritance. | It supports multiple inheritance. |
It can have final, non-final, static and non-static variables. | It has only static and final variables. |
It can have static methods, main method and constructor. | It can’t have static methods, main method or constructor. |
It doesn’t provide full abstraction. | It provides full abstraction. |
It can provide the implementation of interface. | It can’t provide the implementation of abstract class. |
A class may inherit only one abstract class. | A class may inherit several interfaces. |
The abstract keyword is used to declare abstract class. | The interface keyword is used to declare interface. |
Example: public abstract class Test { public abstract void draw(); } |
Example: public interface Drawable { void draw(); } |
No comments:
Post a Comment