Java Object Oriented Programming Concept

In this blog, we can see about the Java Object Oriented Programming Concept, Before that you should know what is object oriented programming.

object oriented programming

What is Object Oriented Programming?

Object-oriented programming is a methodology that helps us to develop and maintain the software easily by supplying some basic concepts.

Java OOP’s Concepts

  • Class
  • Object
  • Inheritance
  • Abstraction
  • Encapsulation
  • Polymorphism
  • Package


Class is a blueprint of an object. It can be visible. And it has collection of variables and methods. In java, you have to use class keyword to create a class. example,

package com.samplecoder;

public class SampleClass {

	// Declare instance variable and class variable here
	// Constructor
	// Define some methods


The object is a runtime entity. It has states and behavior. It will be created at runtime based on its need by using the new keyword. And JVM will allocate some space in Heap Memory and Garbage collector will destroy it and reclaim the memory when it is no longer required.


Inheritance is a way of acquiring parent properties and methods from the child class. It represents IS-A relationship. Two classes involved here, one class called parent class and another one class called child class. The main advantage of inheritance is code reusability. Java does not support multiple inheritance to ambiguity error.


The general definition of abstraction is hiding the internal details and show only functionality to the end user. The best example of abstraction is ATM systems. As an ATM user, we can check the transaction and withdraw money, but we cannot see what happens behind it.


Encapsulation means wrapping the data into the single unit. This is a way of providing the security. The best example of encapsulation is Java POJO class..


The common definition of polymorphism is, An action can carry out in a different manner. In java, polymorphism is broken down into two types.. One is runtime polymorphism and another one is compile time polymorphism. In java compile time polymorphism is achieved by method overloading and runtime polymorphism is achieved by method overloading.


The package is a namespace where we organize the classes and interfaces. It helps us to manage the code in a logical manner when we are working on large projects.