what are uses of object oriented programming

In this article, I am going to tell about the uses and importance of oops.why you should learn only oops.i am going to compare the difference between object-oriented programming and procedure-oriented programming

what are the uses of object-oriented programming?

In procedure-oriented programming, there is no concept of classes and objects. we write all the code in the function itself like in c language.but when it comes to oops all the code is written inside the class itself.to access the data members and member functions of a class we create an instance of a class. Actually class is a blueprint that defines variables and methods common to all objects whereas an object of a class is created to access the data of the class. In simple words, a class is a template or blueprint from which objects are made.
                                                   In oops there are many concepts like data Encapsulation or data hiding, inheritance, polymorphism, access modifiers, exception handling, and Multithreading, etc
Now let us see uses of oops


In object-oriented programming, data is secured using encapsulation. In encapsulation private variables or data members of the class are hidden by methods or functions.we can access only through function name. Generally, set items and get item functions that are used to initialize and get the data by creating an object of that class.

Access Modifiers 

There are three types of access modifiers in class Private, protected and public. if you don't want to share any data with other class, private is a keyword used before any data type. Protected data can be used by only child class basically child class is a class derived from the base or parent class.
But public data members can be shared by other classes by creating an object of that class
Generally, we use public data in class to access methods or variables


Inheritance is a technique of defining a new class using existed class. the newly derived class is called child class.,the class from which it is derived is called parent class. Due to inheritance code is reused.data is extracted from parent to child class, so in this way, the code of class A is reused in class B. Lots of time will be saved.

Exception Handling

Generally, an Exception is an event that disrupts during the execution of a program whereas errors are compilation errors. an exception occurs during the execution of the program. these are of many types like ArrayIndexOutOfBoundExceptions, Arthimethic Exceptions. In object-oriented programming, exceptions are handled using try and catch blocks. So in any language exceptions are handled by try, catch  block.

Post a Comment