Abstraction in java

 Abstraction in java:-               

Abstraction is oop's concept. It is used to hide the sensitive data.

Abstraction can be done in 2 ways

  •  Abstract class
  • Interface

1. Abstract class 

  • A class which is begin with abstract keyword is called Abstract class.
  • Abstract class can contain both concrete function and abstract function.
  • We can not create object for abstract class i.e abstract class can not be instantiated.
  • We can create object for child class of abstract class.
  • We can not define abstract function inside abstract class only can be declared, so it is the responsibility of child class to implement the method/function of abstract class .
  • Abstract class can be extended. 

2. Abstract function

  • The function which is declared with abstract keyword is called Abstract function.
  • It can be declared only inside abstract class.
  • It can not be defined inside abstract class, only can be declared so it is the responsibility of child class to implement abstract method.

Post a Comment

0 Comments