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.
- 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.
- 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.
- Sebesta,”Concept of programming Language”, Pearson Edu
- Louden, “Programming Languages: Principles & Practices” , Cengage Learning
- Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill.
- E Horowitz, “Programming Languages”, 2nd Edition, Addison Wesley