Java OOPs (Object Oriented Programming System) Concepts

Object Oriented Programming is the base of java programming.

Java provides Object Oriented Programming which consist of below concepts

  • Abstraction
  • Encapsulation
  • Inheritance 
  • Polymorphism
In this post, we are going discuss each component in detail


Abstraction-Abstraction emphasizes on the information relevant to the user and hides the internal functionalities.To understand the concept of abstraction in a better way we will see a practical example.
Ex- In a refrigerator we are not concerned about the internal cooling system however, we are only concerned about the refrigerator features.
In simple words, we can say that abstraction hides the complexity and show essential.
In Java abstraction can be achieved by using abstract class and interface.

Encapsulation-In encapsulation objects information in hidden or encapsulated by the class.Information can be hidden from outside world by specifying the variable as private.If we make variable as public it will open to the everyone

Let's take an example to understand the benefit of encapsulation.

The employee is entity class in which age is variable.If we make age as public it will accessible to anyone and can be set to negative value which is not possible for age.
If we make it as private and provide public getters and setter the value can set on this by setter and in setter method, we can write code to avoid negative value thus we have full control on the variable age.

Inheritance-Inheritance in java provides the mechanism of code reusability.With inheritance, we can reuse the code (variables and method) from super class or base class in the subclass or derived class.
In another word we can say with inheritance child class acquires the behavior of the parent class.
Inheritance in java can be achieved by using extend keyword.Multilevel inheritance is possible in java but multiple inheritance is not possible.We will explain inheritance with the example in coming tutorial.

Polymorphism-In Java polymorphism is used when we want the same method to behave differently depending upon the object.In Java polymorphism can be achieved by Overriding and Overloading.
For Example-If we have command speak to different animals all will behave differently.
In coming tutorial, we will discuss in detail.

Hope you like the tutorial.

You may interested in JVM Memory Allocation.

Give you suggestion in comments.If you like the post Share with your friends on social network.















Java OOPs (Object Oriented Programming System) Concepts Java OOPs (Object Oriented Programming System) Concepts Reviewed by JavaInstance on 4:44:00 AM Rating: 5

1 comment:

Powered by Blogger.