INTRODUCTION
Procedural programming is about writing procedures or methods that perform operations on the data. Programmers wanted to map code instructions with the real world making the code short, clean, and easy to understand. Having said that, let us understand what is OOP...
What is OOP?
OOP stands for Object-Oriented Programming. Procedural programming is about writing procedures or methods that perform operations on the data, while object-oriented programming is about creating objects that contain both data and methods. Solving a problem by creating objects is one of the most popular approaches in programming. This is called object-oriented programming.
Object-oriented programming has several advantages over procedural programming:
• OOP is faster to execute
• OOP provides a clear structure of the program
• OOP helps to keep the Java code DRY "Don't Repeat Yourself", if you don't know what DRY means then Click here
•OOP makes it possible to create fully reusable applications with less code and is easy to debug.
Classes and Objects In OOP
Class
A class is a blueprint for creating objects. Think of it like a website where you can apply for your entrance exam. Many of us, must have given national-level entrance exams, wherein we visit the portal where we have to fill in our details such as name, qualification, father's name, etc. The details are not filled, this is a class.
Object
When we fill in our details in that online form/portal, then what is created is called an object. An object is an instantiation of a class. When a class is defined, a template is defined. Memory is allocated only after object instantiation.
OOPs Terminology
ABSTRACTION
Abstraction refers to hiding the details. If you visit the Apple store, to buy an iPhone, you find that the iPhone has cool features. It has a fingerprint sensor, face unlock, dynamic island, great UI/UX, etc. You don't generally ask the shopkeeper there how this feature was made, right? Even, there are rare chances that the seller knows how face unlock is being coded. This is called Abstraction, hiding the internal details.
Encapsulation
The act of putting various components together in a capsule/box. Again take the example of the iPhone, GPS, Camera, Music system, Recorder, Calender, etc all inside a single iPhone. This is called Encapsulation. In Java, encapsulation means that the sensitive data can be hidden from the users.
Inheritance
The act of deriving new things from the existing ones is called Inheritance. For example, just a decade ago we didn't have smartphones as we see today. Most people had Nokia mobile phones where you could only call someone and receive calls, and few games like Snake and Ladder. But, today's smartphones are totally different from previous phones. This is called Inheritance, to upgrade, to derive new things out of the existing ones.
Polymorphism
One entity exists in many other forms. A smartphone can act like a Camera, Video recorder, Web browser, PSP, etc. This is called polymorphism.
That's a wrap
Thank you for Reading my Article📄 Hope it adds value to the community💙
Follow me on Twitter : vinayakstwt🕊️
Follow me on Hashnode VINAYAK PANCHAL✅