Monday , July 4 2022
Home / Java / Object Oriented Programming in Java

Object Oriented Programming in Java

Object Oriented Programming in Java

Object Oriented Programming is a concept of objects and relating everything in real world. It allows us to think about everything in the universe as an object so we can easily work with them. In this Java programming tutorial, we will learn basic pillars of Object Oriented Programming.

Object Oriented Programming has 4 pillars:

  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorhpism



“Eliminate the Irrelevant, Amplify the Essential”

Abstraction image oop

Abstraction is to focus on the essential and discard the irrelevant. In a way this does not make sense unless you have a scope. Example in the image above the vet is a doctor of animals her view of the cat that is important to her would be the parts of the cat while thing like the cat favorite toy might not be of relevance to her. Whereas for the owner of the cat her view of the cat is different from the Vet.


“Hiding the Unnecessary”

Encapsulation image oop

Encapsulation is hiding the unnecessary. Meaning things that you do not want other people/classes to know are to be hidden. For example in the image the professor do not need to know how a student does her assignment. He is more interested in the end product.

In a way encapsulation protect the system, since it hides stuff that can be vulnerable to malicious attack. There are also many other drawbacks to create a system without encapsulation. You can find it out in our book chapter.


“Modeling the Similarity”

Inheritance image oop

Similarities often exist in the world. As shown in image above, one could easily see that there are some similarities between the two President of United States, George H.W Bush (41st President) and George W. Bush (43rd President).
George W. Bush is a son of George H.W Bush. He inherits biological features from his father, at the same time, has his own unique feature that one could identify him as George W. Bush. This bring us to the idea of inheritance that models a “is a” relationship between objects.



“Same Function different behavior”

The word “Polymorphism” comes from two Greek words, “many” and “form”. We can illustrate the idea of polymorphism easily using the scenario where different animals are asked to “speak”. As you can see from the image above, each animal has their own way of “speaking”. So, when the person asks all the animals to “speak”, every animal responds in their own way. This illustrates the power of polymorphism where different instances can be treated the same way.

Learn more Java object oriented programming in this Urdu/Hindi tutorial video:

About Faheem

An adaptable and responsible Software Engineer, who enjoys working with computers and the opportunity to learn new skills and work with new technologies is particularly attractive to me.

Check Also

JAVA #32 – Java application using SQL server (Part: 01)

  In this part we made the GUI front end of a Application.

Leave a Reply

Your email address will not be published.