What is OOP?

OOP abbreviation stands for Object-Oriented Programming. Thus, we need to define objects firstly. Probably, you have just mastered loops and arrays, created your first application, and now it appears that there are something like objects. Now, you will face a new world of terms, be ready for that. Moreover, we want to notify that this topic requires much attention, because it will become the fundamental in your future work.

What does object stand for?

Programming is quite a difficult thing. Nobody wants to complicate it, but everyone wants to make it easier and faster to work with. OOP and objects were designed to make your life easier.

Working earlier, you most likely used Scanner for reading the symbols input by the user. It is quite convenient, isn’t it? You just need to declare


Scanner scan = new Scanner(System.in);

Creating a new object of Scanner type, and now you have an opportunity to set different methods. You do not care how does it work, as the main factor is that you can reuse it again and again. Quite cool, right?

What is more important is that you will be able to create your own class and objects in the nearest future.

Surely, you have used Scanner many times. It may have included different parameters and names – scan, scanner, sc or sc1. All of these are different objects of a single class.

Every objects has its own properties. For example, the properties of a car: model, color, size, etc.

Then, every object has methods (those actions it is available to perform). For example, the methods of a car: slow down, accelerate, etc.

It can be said that the friend of yours is an object of Human class, a big Rottweiler is an object of Dog class, containing general methods and properties, but with different individual parameters.

Apart from the basic terms as class and object, we want to discuss the main OOP principles like inheritance, encapsulation, polymorphism (keep in mind these terms as you will likely use them during the interview).

Principle #1. Inheritance

So what does inheritance stand for?

You may think of it as a simplifier. Now, you know that you can just create objects and classes instead of rewriting the code many times. Inheritance allows you to save time during a new class creation. Just imagine that you have a cat, which has such properties as name, colour, breed, etc. This class has such methods as sleep, eat, play, and purr. Now, let’s assume that you need to create a new class named Kitty. It also has name, colour, and size, it can also sleep, eat, play, purr. However, it may know one more method like Search For A Mummy.

With the help of inheritance, all the class methods and properties should not be rewritten one more time. You can just specify that Kitty class inherits from Cat class, then adding required methods and properties. It seems to be extremely useful and convenient, right?

Principle #2. Encapsulation

Encapsulation stand for providing the security in Java.

The matter is that every application has certain amount of data and its access should not be provided to all the participants. For example, will it be interesting to play a game if you have an opportunity to change your scores? Therefore, encapsulation allows you to manage the access levels in the application.

Principle #3. Polymorphism

It is another work simplifier. The main sense of polymorphism is that you can give the same names to the methods that have the common logic, but different types of data. However, it may seem strange to you, but some programming languages do not have this principle, and you need to keep in mind the names of 5 methods due to the fact that they work with different types of data.

Thus, you have learned the main OOP principles. One more time, it will become the fundamental basics in your future work, so you should master this topic completely.

Leave a Comment