The four fundamental ideas of Object-Oriented Programming are Encapsulation, Abstraction, Inheritance, and Polymorphism. OOP allows programmers to approach software development as if they were dealing with real-world objects. People in real life have the skills and expertise to do a variety of tasks. Objects in OOP feature fields for storing knowledge, state, and data, as well as the ability to perform a variety of operations. The basic terms we need to know before getting more into OOP are Object, Class, Method, and Instance.
Object – A class’s instance
Class – A model that describes an object’s functionality
Method – Changing the state of a class applies to all other instances of the class
Instance – Is similar to an object. The blueprint used to build the product is an instance of the class.
Let’s move on to the four fundamental ideas of Object-Oriented Programming:
Encapsulation
When objects are encapsulated inside a class, they each have a private state. Other objects can’t directly access this state, but they can only use a list of public functions to get at it. These functions allow the object to control its own state and no other class has access to it unless access is granted. As a developer, you must use the given ways to communicate with the object. The state of a class invoked by a method created a bond between the private state and public methods.
Abstraction
Abstraction is a continuation of encapsulation. To show just relevant information to an object, data is selected from a large pool. Abstraction is the technique used to get, remove, or select user data from a bigger pool. In the case of abstraction, you can use the same info gathered for a different app to power other programs with little or no coding changes.
Inheritance
Inheritance is the process through which one object gains access to all of the properties of another without actually changing anything about the original. For instance, a child gets personality qualities from both of their parents. Reusability is a significant benefit of inheritance. The existing class’s fields and methods can be reused. Inheritance might be single, multiple, multilevel, hierarchical and hybrid, in Java.
Polymorphism
Polymorphism makes it possible to utilize a class in the same way as its parent, which eliminates the possibility of confusion. As a result, each child sub-class retains its own functions and methods. Each of the child sub-classes should have unique variations.
In a conclusion, Object-Oriented Programming refers to programming languages that use objects. The goal is to implement real-world concepts, keep data and the functions that operate on it separate such that no other part of the code may access it, except for that function.
References:
https://info.keylimeinteractive.com/the-four-pillars-of-object-oriented-programming
From the blog CS@worcester – Xhulja's Blogs by xmurati and used with permission of the author. All other rights reserved by the author.