Abstraction and encapsulation

ABSTRACTION AND ENCAPSULATION

Abstraction: Abstraction is the technique of hiding the implementation details and showing only functionality to the user. 

For example, when we call any person we just dial the numbers and are least bothered about the internal process involved.

Abstract class

  • A class that can contain abstract keyword is known as an abstract class.
  • Abstract methods do not have body.
  • It forces the user to extend the implementation rather than modification.
  • An abstract class cannot be instantiated.

Abstract Method
  • If a method is declared as an abstract, then it is called abstract method.
  • It does not have implementation.
  • It contains method signature but not method body.

Encapsulation: Encapsulation is the mechanism of binding together variables and functions into a single unit. 
  • Encapsulation is used for information hiding. 
  • Encapsulation can be achieved by declaring variables of class as private.

LEAVE A REPLY










Related topics

Please use contact page in this website if you find anything incorrect or you want to share more information about the topic discussed above.