Abstraction:
Abstraction is a process of hiding the implementation details and showing only functionality to the user. Abstraction is a process of hiding the implementation details and showing only functionality to the user.
There are two ways to achieve abstraction in java
- Abstract class (0 to 100%)
- Interface (100%)
Abstract Class : A class that is declared with abstract keyword, is known as abstract class in java. It can have abstract and non-abstract methods (method with body). An abstract class is never instantiated. It is used to provide abstraction. Although it does not provide 100% abstraction because it can also have concrete method.
abstract class class_name { }
Abstract Method: Method that are declared without any body within an abstract class is known as abstract method. The method body will be defined by its subclass. Abstract method can never be final and static. Any class that extends an abstract class must implement all the abstract methods declared by the super class.
abstract return_type function_name ();
No comments:
Post a Comment