Features of OOP
OOP stands for Object Oriented Programming and the language that support this Object Oriented programming features is called Object oriented Programming Language. An example of a language that support this Object oriented features is C++.
Features of Object oriented Programming
The Objects Oriented programming language supports all the features of normal programming languages. In addition it supports some important concepts and terminology which has made it popular among programming methodology.
The important features of Object Oriented programming are:
- Data Hiding
Let us see a brief overview of these important features of Object Oriented programming
But before that it is important to know some new terminologies used in Object Oriented programming namely
In other words object is an instance of a class.
These contain data and functions bundled together under a unit. In other words class is a collection of similar objects. When we define a class it just creates template or Skelton. So no memory is created when class is created. Memory is occupied only by object.
main ( )
In other words classes acts as data types for objects.
The functions defined inside the class as above are called member functions.
Here the concept of Data Hiding figures
This concept is the main heart of an Object oriented programming. The data is hidden inside the class by declaring it as private inside the class. When data or functions are defined as private it can be accessed only by the class in which it is defined. When data or functions are defined as public then it can be accessed anywhere outside the class. Object Oriented programming gives importance to protecting data which in any system. This is done by declaring data as private and making it accessible only to the class in which it is defined. This concept is called data hiding. But one can keep member functions as public.
So above class structure becomes
main ( )
The technical term for combining data and functions together as a bundle is encapsulation.
Inheritance as the name suggests is the concept of inheriting or deriving properties of an exiting class to get new class or classes. In other words we may have common features or characteristics that may be needed by number of classes. So those features can be placed in a common tree class called base class and the other classes which have these charaterisics can take the tree class and define only the new things that they have on their own in their classes. These classes are called derived class. The main advantage of using this concept of inheritance in Object oriented programming is it helps in reducing the code size since the common characteristic is placed separately called as base class and it is just referred in the derived class. This provide the users the important usage of terminology called as reusability
This usage is achieved by the above explained terminology called as inheritance. Reusability is nothing but re- usage of structure without changing the existing one but adding new features or characteristics to it. It is very much needed for any programmers in different situations. Reusability gives the following advantages to users
It helps in reducing the code size since classes can be just derived from existing one and one need to add only the new features and it helps users to save their time.
For instance if there is a class defined to draw different graphical figures say there is a user who want to draw graphical figure and also add the features of adding color to the graphical figure. In this scenario instead of defining a class to draw a graphical figure and coloring it what the user can do is make use of the existing class for drawing graphical figure by deriving the class and add new feature to the derived class namely add the feature of adding colors to the graphical figure.
Polymorphism and Overloading:
Poly refers many. So Polymorphism as the name suggests is a certain item appearing in different forms or ways. That is making a function or operator to act in different forms depending on the place they are present is called Polymorphism. Overloading is a kind of polymorphism. In other words say for instance we know that +, – operate on integer data type and is used to perform arithmetic additions and subtractions. But operator overloading is one in which we define new operations to these operators and make them operate on different data types in other words overloading the existing functionality with new one. This is a very important feature of object oriented programming methodology which extended the handling of data type and operations.
Thus the above given important features of object oriented programming among the numerous features it have gives the following advantages to the programming world. The advantages are namely
• Data Protection or security of data is achieved by concept of data hiding
• Reduces program size and saves time by the concept of reusability which is achieved by the terminology of Inheritance
• Operators can be given new functions as per user which extends the usage.