Tutorials Hut

Java Concepts of OOPs

What is OOPs

OOPs stands for object oriented programming. Any programming languages which follows principals of OOP is called OOP (object oriented programming) language. In world of OOP everything is an object. We look in detail on concepts of OOPs in this article. 

Before OOP programming languages (java, C++ etc.) procedural programming languages were popular and in use for example C, COBOL, Fortran and etc. These programming languages used to write logic in procedure or steps without having any object or concept of object.

What Is Class and Object

OOP is based on objects and classes so it is important to know what is class and object, see below definition of class and object.

Class – Class is a blue print or skeleton or representation of any real world object for example Car class will be skeleton or blue print of any Car object in real world.

Object – Object is instance of Class and we can create as many objects as we want from Class for example car1, car2, car3 etc can be objects of Car class.

Example of Object and Class:
In this example Car is a class and car is object of Car class, created in main method.

public class Car {
   String color;
   int maxSpeed = 100
   public Car(){ //Constructor without arguments
   public Car(String color){ //Constructor with arguments
 	System.out.println("Passed argument is: " + color);
   public void startCar() {
  System.out.println("Car started using method startCar”);
public static void main(String []args) {
// Below line of code will create an object car for Car class
      Car car= new Car( "red" );

Object is created by this line of code in above example:
Car car= new Car( “red” );

Compile and run above code, below output will come:
Passed argument is: red

Advantage of OOPs

Below are few advantages of OOPs:

  1. OOP is structured and very easy to understand.
  2. OOP has everything in object of classes and we can relate these classes and their objects to real life objects for example Car, Tree, School etc.
  3. Reusable components can be easily developed using OOP.
  4. OOP makes code readable and verbose.
  5. OOP enables easy maintenance and update of code.

OOPs Concepts

Below are OOPs concepts, in coming articles we will see details of them:

  1. Inheritance – On class Inherits the properties and attributes of other class.
  2. Abstraction – Provides abstract details and leaves implantation to another class which uses abstract class.
  3. Polymorphism – If same thing takes more than one form even though name looks same called polymorphism.
  4. Encapsulation – Holding attributes and methods within class is called encapsulation.

Once we learn all these OOPs concepts we will try to understand what is association, aggregation(has-a) and composition(is-a), cohesion and coupling.

OOPs Diagram:

OOPs Concepts
OOPs Concepts


Oracle has reference article on OOPs: Java OOPs 

Next Articles

Leave a Reply

Your email address will not be published. Required fields are marked *