Object oriented programming is a programming paradigm that works around objects. it is a way or class of programming that uses objects and classes to create real-world applications. OOPs is not a programming language. it is a way to give shape to real-world objects in a programming language.
For example let’s say a car has different brands, colors, functionality, and features. some functions are hidden from users like we don’t know how the internal functionality of a function works and how two things are connected with each other. and the same happened with object-oriented programming. Oops, are used to bind data and functions together to make a new feature using inheritance, hiding, polymorphism, etc.
Object-oriented programming is not connected with a specific programming language. it is a feature that can be implemented by programming language or not. just like c programming is not an Object-oriented programming language, whereas C++ has both OOPs and procedural programming language features. and Java is a complete Object-oriented programming language.
Features of Object-oriented programming.
In Object-oriented programming Inheritance allow a class to share their features like methods, functions, and variables with another class. if the attributes and behaviors are defined in a class then we can inherit that class into another class to access these attributes and behaviors. and the class that feature is inherited is called the parent class and the class that inherits the functionality of that class is called the child class.
Encapsulation means hiding some information inside an object and only exposing the necessary information to the outside world. this feature is used to hide some private data like application keys from the outside world. that help to secure the application from others.
when we declare some methods inside a class and when an object is created using the class, the data encapsulated in that object. to use this feature in OOPs we need to declare some features private and some features in public mode.
A private method can only be accessible inside the class. and a public method can access from outside the class.
In OOPs abstraction means only selecting or providing the information that needs to be accessible from the outside world to work an object. for example, in a car, only the needed parts like a brake, accelerator, steering, and gear are accessible by the user. another functionality is hidden inside the parts.
Polymorphism means sharing behaviors by objects. we can make the same object work on different functionality. in OOPs programming we can declare functions with the same name with different arguments and this feature is called method overriding. or we can declare the same function in two classes with the same name and this feature is called method overloading.
Method overriding is also called compile-time polymorphism and method overloading is also called run-time polymorphism.
Benefits of using OOPs in programming.
- Using Object-oriented programming we can make a complex application in a simple form.
- We can use the code multiple times and need to declare only one time.
- we can easily debug our application.
- we can hide some internal data from the users. that make our system more secure.