
You can remember it by saying “A PIE”
A stands for Abstraction
P stands for Polymorphism
I stands for Inheritance
E stands for Encapsulation.
Let’s see what they mean:
- Inheritance: Inheritance is a process where one class acquires the properties and methods of another. Eg:, Class A extends B
- Encapsulation: Encapsulation in Java is a mechanism of wrapping up the data and code together as a single unit. In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class. Eg.; private variable.
- Abstraction: Abstraction is the technique of hiding the implementation details from the user and only providing the functionality to the users. In java it is achieved through Interfaces and Abstract classes.
- Polymorphism: Polymorphism is the ability of a variable, function or object to take multiple forms or you can sau exist in multiple forms. There are two types of polymorphism in Java: compile-time polymorphism and runtime polymorphism. We can perform polymorphism in java by method overloading and method overriding.