In simple word abstraction is the process of showing relevant functionalities to users and hide the implementation details. Just like users only focus on what the object does instead of how to do it. There are two ways to achieve abstraction in Java - Abstract class and Interface.
Abstract Class
- Abstract classes may or may not contain abstract methods. It can contain abstract or concrete methods. That's why it is partially abstract
- The class must be declared abstract if a class has at least one abstract method
- It cannot be instantiated if a class is declared abstract
- If subclass is inherited from abstract class it must provide all abstract methods implementation inside it. If subclass is also abstract it can include abstract methods
- Abstract class doesn't support multiple inheritance. (it can extends abstract or concrete class)
- Constructor is allowed in abstract class
- Abstract class can have final, non-final, static and non-static variables
- Abstract class can provide the implementation of interface
No comments:
Post a Comment