Abstract Thinking: Unlocking Efficiency and Clarity in Code
ABSTRACTION
In Java, abstraction
is a powerful concept that allows us to manage complexity by focusing on
essential details while hiding unnecessary intricacies. Modifying a class or
method with the keyword abstract can be simply called abstraction.
Example:-
👇Abstract
method can be kept only inside an abstract class.
👉You can use the abstract class as a super class reference after Upcasting. 👇
💁You can run
the method of the abstract class through the super keyword.
Super.calculate();
💁And also you
can run the method of the abstract class as,
Cal.Calculate();
💁An object cannot be created from an abstract class. So abstract class cannot have constructor.
But after java 8 abstract classes cannot create object but they are given the opportunity to get a constructor.
Advantages of
abstraction📝
Comments
Post a Comment