DEV Community

nantha kumar
nantha kumar

Posted on

Abstraction

What is abstraction :

  1. Abstraction means hiding implementation details and showing only essential features to the user.

How to achieve abstraction :

  1. Using abstract keyword

Where you used abstract keyword :

  1. We can use abstract keyword in class level and method level.

Can an abstract class have:

Constructors? ✅
Private methods? ✅
Static methods? ✅
Final methods? ✅

Answer : Yes

Notes :

  1. abstract class does not have method definition.

  2. We can't create object directly.

Can we create an object of an abstract class?

  1. Answer: ❌ No But reference can be created
BankService service = new UPIService();
Enter fullscreen mode Exit fullscreen mode

Can an abstract class have instance variable ?

Answer : Yes

Top comments (0)