OOP stands for Object-Oriented Programming.
Difference between Procedural programming and OOPs?
A 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. The main aim of OOPs is to bind the data and the functions together so that no other part of the code can access this data except that function.
Object-oriented programming has several advantages over procedural programming:
1. OOP is faster and easier to execute.2. OOP provides a clear structure for the programs
3. OOP makes the code easier to maintain, modify and debug. It works on DRY concepts ="Don't Repeat Yourself.
4. OOP makes it possible to create full reusable applications with less code and shorter development time.
What do you mean by class and objects?
Classes and objects are the two main aspects of object-oriented programming.
A class is a blueprint or set of instructions from which objects are created. It defines a class that models the state and behavior of a real-world object. Object is an instance of a class. An object in OOPS is nothing but a self-contained component which consists of methods and properties to make a particular type of data useful,
For example:
Fruits -- It is a class.
Apple, banana, orange -- They are objects of the class.
The four pillars of OOP are Abstraction, Encapsulation, Inheritance, Polymorphism.
- Abstraction: Abstraction is the process of extracting the essential/necessary features of an entity/object to the outside world and hide the other irrelevant information. The best example to explain the concept of abstraction is TV Remote: to open your TV we only have a power button, It is not required to understand how infra-red waves are getting generated in TV remote control.
- Encapsulation: Encapsulation means wrapping up data and member function (Method) together into a single unit i.e. class. Encapsulation automatically achieves the concept of data hiding providing security to data by making the variable as private class and expose the property to access the private data which would be public.
- Inheritance: The ability to create a new class from an existing class. Inheritance is when an object acquires the property of another object. Inheritance allows a class (subclass) to acquire the properties and behavior of another class (super-class). It helps to reuse, customize and enhance the existing code. So it helps to write a code accurately and reduce the development time.
- Polymorphism: Polymorphism is derived from two greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism means "many forms". A subclass can define its own unique behavior and still share the same functionalities or behavior of its parent/base class. A subclass can have its own behavior and share some of its behavior from its parent class not the other way around. A parent class cannot have the behavior of its subclass.
Hope you like the content of the blog and provide the valuable feedback in the comment section.
0 Comments