Posted On: Jan 04, 2021
Abstract class | Interface |
---|---|
(1) Abstract class can contain abstract and non-abstract methods that should be declared with the abstract keyword. | The interface should be declared with the interface keyword. It can contain only abstract methods. |
(2) Abstract class doesn't support multiple inheritances. | The interfacesupports multiple inheritances. |
(3) Abstract class can contain final, non-final, static, and non-static variables. | The interface contains only static and final variables. |
(4) Abstract class can provide the implementation of the interface. | Interface can't provide the implementation of the abstract class. |
(5) An abstract class can be extended by using the "extends" keyword. | An interface can be implemented by using the "implements" keyword. |
(6)For instance, public abstract class Shape{ public abstract void draw(); } | Example: public interface Drawable{ void draw(); } |
Never Miss an Articles from us.
Object-oriented programming (OOP) is a computer programming technique that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field ...
Structured Programming can be defined as a programming Approach in which the program is made as a single structure. Lines or blocks of codes are written and executed in a sequential manner such as one...
A class is the most important part of object-oriented programming which is used for the purpose of creating objects. It is defined as the template of similar types of objects consists of a declaration...