Abstract methods and abstract classes
Day 12:
What is Abstraction?
Hiding the Implementation details. Interface allows 100% Abstraction, whereas Abstraction allows 0 to 100% abstraction.
Abstract methods and abstract classes
Abstract methods and abstract classes enable partial abstraction. They allow to define a blueprint for future implementations while leaving specific details to be completed by subclasses.
Abstract Method
An abstract method is a method that:
If a class has Abstract methods then the specific method and class both needs to be declared Abstract. Subclasses must implement all the abstract methods, unless they are also abstract.
Abstract Class
A class declared with the abstract keyword is Abstract class. It can have all methods as abstract or no methods as abstract. Subclasses must implement all abstract methods, unless they are also abstract.
Example:
Hope Abstraction is understood well . Let's see polymorphism Tomorrow. Happy Learning :)