× Please, log in to give us a feedback. Click here to login

You must be logged to download. Click here to login


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

The 4 pillars of Object Oriented Programming in Java

Meet in this article the main pillars, as well as differences to structured programming and the main advantages of OOP.

Software development is extremely broad. In this market, there are several programming languages, following different paradigms. One of these paradigms is the Object Oriented, which is currently the most widespread of all. This is because it is a standard that has evolved a lot, mainly geared to safety issues and code reuse, which is very important in the development of any modern application.

The Object Oriented Programming (OOP) refers to a pattern of development that is followed by many languages, such as C# and Java. Then, we will understand the differences between OOP and Structured Programming, which was widely used for some years, mainly with C. This standard language is based on four pillars that we will see throughout this article. Additionally, OOP has several advantages in its use that will also be seen and explained.

Structured Programming vs. Object Oriented Programming

In Figure 1 we see a very clear comparison of structured programming and object oriented programming with respect to data. Note that, in the structured paradigm, we have procedures (or functions) that are applied globally in our application. In the case of object orientation, we have methods that are applied to the data of each object. Essentially, the procedures and methods are the same and are differentiated only by their scope.

Figure 1. Structured x Object Orientation

C language is the main representative of structured programming. It is considered a low-level language, which is currently not used for very large projects. Its main use due to the low level, is programming for embedded systems or others in which the knowledge of the hardware is necessary for a good program.

This placement brings us to an important detail: structured programming, when done well, has a superior performance to what we see in object-oriented programming. This is because it is a sequential paradigm, in which each line of code is executed after another, without many detours, as shown in OOP. In addition, thestructuredparadigm usually allows more liberties with the hardware, which ends assisting in the performance issue.

However, object-oriented programming brings other points that end up being more interesting in the context of modern applications. As application performance is not a major concern in most applications (due to the current computer processing power), the object-oriented programming became widespread. This diffusion takes much the issue of code reuse and system representative capacity much closer than we would see in the real world.

We will see in detail these and other issues that relate to object-oriented programming. As developers, it is our mission to understand what are the advantages and disadvantages of each programming paradigms and choose the best for our application. The choice of a language should also be present in this choice.

The 4 pillars of Object Oriented Programming

To understand exactly what it is object orientation, let us understand what are the requirements of a language to be considered into this paradigm. For this, the language must meet four very important topics:


Abstraction is one of the most important points within any object-oriented language. As we are dealing with a representation of a real object (which names the paradigm), we have to imagine what that object will perform within our system. There are three points that should be taken into consideration in this abstraction.

The first point is to give an identity to the object that we create. This identity must be unique within the system so there is no conflict. In most languages, there is the concept of packages (or namespaces). In these languages, the identity of the object can not be repeated within the package, not necessarily the entire system.

The second part concerns the object's characteristics. As we know, in the real world every object has elements that define it. Within the object-oriented programming, these characteristic properties are named. For example, the properties of an object "Dog" could be "Size", "Race" and "Age".

Finally, the third part is define the actions that the object will perform. These actions, or events, are called methods. These methods can be extremely variable, ranging from "TurnOn()" in a lamp object to "Bark()" in a dog object.


Encapsulation is one of the main techniques that defines the object-oriented programming. It is one of the elements that add security to the application in an object-oriented programming because of hiding the properties, creating a sort of black box.

Most object-oriented languages implement encapsulation based on private property, related to special methods called getters and setters, which will return and set the property value, respectively. This attitude prevents direct access to the object's property by adding another application security layer.

To do a parallel with what we see in the real world, we have encapsulation into other elements. For example, when we click the button to connect the television, we do not know what's going on internally. We can then say that the methods that connect the TV are encapsulated.


Code reuse is one of the great advantages of object-oriented programming. Much of this happens as a matter which is known as inheritance. This feature optimizes the production time and the application code lines.

To understand this feature, let's imagine a family: a child, for example, is inheriting characteristics from their parents. Parents, in turn, inherit something from grandparents, which means that your child also does, and so on. In object orientation, the question is exactly that. The object down the hierarchy will inherit characteristics of all the objects above it, their "ancestors". The inheritance from the characteristics of the above is considered direct object inheritance, while the others are considered indirect inheritance. For example, in the family, the child inherits the parent directly and indirectly grandfather and great-grandfather.

The issue ofinheritancevaries greatly from language to language. In some of them, such as C++, there is the issue ofmultiple inheritance. This essentially means that the object can inherit characteristics of various "ancestors" while directly. In other words, each object can have as many parents needed. Due to problems, this practice was not widespread in most modern languages, using other tricks to create a kind of multiple inheritance.

Other object-oriented languages such as C#, bring a base object for everyone else. The object class provides features for all objects in C#, are created by the user or not.


Another essential point in object-oriented programming is called polymorphism. In nature, we see animals that are capable of changing its shape as needed, and it is this idea that comes polymorphism in object orientation. As we know, the child objects inherit the characteristics and actions of their "ancestors". However, in some cases, it is necessary that the actions for a same method to be different. In other words, the polymorphism consists of changing the inner workings of a method inherited from a parent object.

As an example, we have a generic object "Appliance". This object has a method, or action, "TurnOn()". We have two objects, "TV" and "Fridge", which won't be connected in the same way. So you must, for each of the child classes, rewrite method "TurnOn()".

Regarding the polymorphism, worth some observations. As this is an issue that is closely connected toinheritance, understandboth together is a good idea. Another point is the fact that the programming languages implement polymorphism in different ways. C#, for example, makes use of virtual method (with the virtual keyword) which can be redeployed (with the override keyword) in the child classes. In Java, only the "@Override" attribute is required.

These four pillars are essential in the understanding of any object-oriented language and object orientation as a whole. Each language will implement these pillars in a way, but essentially it's the same. Only the issue of inheritance, as mentioned, which may bring more rapid changes, such as the presence of multiple inheritance. Moreover, encapsulation is also done in different ways in different languages, although the getters and setters are almost ubiquitous.


Java is most likely the programming language most used in the current market. Aided by the presence of the JRE (Java Runtime Environment), or variations of it, in almost all electronic devices of the moment, the Java language is a big hit among developers. The success of the language increased even more with Google Android, which chose the Java as the preferred language application development.

Java implements the four pillars of intuitive form, which facilitates the understanding by the developer. Abstraction, the first pillar, is implemented through classes, which contains properties and methods, quite simple. Since encapsulation is accomplished through private properties, aided by special getters and setters methods, as shown in Listing 1. It is worth mentioning the keyword "this" shown in setId() method. This keyword works as a representative of the current class, a self-reference to the object itself.

Listing 1. Encapsulation in Java

private int id;

public int getId() {
   return id;

public void setId(int id) {
   this.id = id;

Inheritance issues and polymorphism in Java are a bit more complex. Java has single inheritance, meaning that each class can inherit from only one other. However, the Java has the calls to interfaces that have properties and method signatures. These interfaces must be implemented to function, which means that a class can implement multiple interfaces and inherit from only one class. The question of polymorphism, the @Override attribute is responsible for reporting to the Java that the method in question is being rewritten.


Throughout this article, we tried to list the elements that make object-oriented programming a success at the time. We saw the four pillars of this paradigm and understood how they are implemented in some of the most used languages in the development market. Furthermore, we understand some of the advantages that have made the object-oriented programming a great success for the development of modern systems.

Web developer and passioned for web design, SEO and front end technologies.

What did you think of this post?
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!

> More info about MrBool Credits
You must be logged to download.

Click here to login