What are basic Object oriented programming concepts?



The basic Object-oriented programming concepts are:

Inheritance

 Inheritance can be defined as the process where one (parent/super) class acquires the properties (methods and fields) of another (child/sub). With the use of inheritance, the information is made manageable in a hierarchical order.

Polymorphism

Polymorphism is the ability of an object to perform different actions (or, exhibit different behaviors) based on the context.

Abstraction

Abstraction is a process of hiding the implementation details from the user, only the functionality will be provided to the user. In other words, the user will have the information on what the object does instead of how it does it.

In Java, abstraction is achieved using Abstract classes and interfaces.

Encapsulation

Encapsulation in Java is a mechanism for wrapping the data (variables) and code acting on the data (methods) 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. Therefore, it is also known as data hiding. To achieve encapsulation in Java −

  1. Declare the variables of a class as private.
  2.  Provide public setter and getter methods to modify and view the variables values.

Advertisements