Object-oriented programming (OOP) languages support important concepts like inheritance, polymorphism, encapsulation, and data hiding. These features allow for code reusability through inheritance, where derived classes can inherit properties from base classes. Data hiding protects data by making it private to classes, while encapsulation bundles data and functions together. Polymorphism allows functions to behave differently depending on context through operator overloading. Overall, OOP improves code organization and security through these key pillars.
Download as DOC, PDF, TXT or read online on Scribd
100%(1)100% found this document useful (1 vote)
771 views
Features of OOP
Object-oriented programming (OOP) languages support important concepts like inheritance, polymorphism, encapsulation, and data hiding. These features allow for code reusability through inheritance, where derived classes can inherit properties from base classes. Data hiding protects data by making it private to classes, while encapsulation bundles data and functions together. Polymorphism allows functions to behave differently depending on context through operator overloading. Overall, OOP improves code organization and security through these key pillars.
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7
Features of OOP
Author : Exforsys Inc. Published on: 22nd Oct 2006
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 hich has made it popular among programming methodology. The important features of Object Oriented programming are! Inheritance Polymorphism "ata #iding $ncapsulation O%erloading &eusability Let us see a brief o%er%ie of these important features of Object Oriented programming 'ut before that it is important to (no some ne terminologies used in Object Oriented programming namely Objects Classes Objects: In other ords object is an instance of a class. Classes: These contain data and functions bundled together under a unit. In other ords class is a collection of similar objects. )hen e define a class it just creates template or *(elton. *o no memory is created hen class is created. +emory is occupied only by object. Example: Class classname { Data Functions }; main ( ) { classname objectname1,objectname2,..; } In other ords classes acts as data types for objects. Member functions: The functions defined inside the class as abo%e are called member functions. #ere the concept of "ata #iding figures Data Hiding: This concept is the main heart of an Object oriented programming. The data is hidden inside the class by declaring it as pri%ate inside the class. )hen data or functions are defined as pri%ate it can be accessed only by the class in hich it is defined. )hen data or functions are defined as public then it can be accessed anyhere outside the class. Object Oriented programming gi%es importance to protecting data hich in any system. This is done by declaring data as pri%ate and ma(ing it accessible only to the class in hich it is defined. This concept is called data hiding. 'ut one can (eep member functions as public. *o abo%e class structure becomes Example: Class classname { private: datatpe data;
public: !ember "unctions }; main ( ) { classname objectname1,objectname2,..; } Encapsulation: The technical term for combining data and functions together as a bundle is encapsulation. Inheritance: Inheritance as the name suggests is the concept of inheriting or deri%ing properties of an exiting class to get ne class or classes. In other ords e may ha%e common features or characteristics that may be needed by number of classes. *o those features can be placed in a common tree class called base class and the other classes hich ha%e these charaterisics can ta(e the tree class and define only the ne things that they ha%e on their on in their classes. These classes are called deri%ed class. The main ad%antage of using this concept of inheritance in Object oriented programming is it helps in reducing the code si,e since the common characteristic is placed separately called as base class and it is just referred in the deri%ed class. This pro%ide the users the important usage of terminology called as reusability Reusabilit: This usage is achie%ed by the abo%e explained terminology called as inheritance. &eusability is nothing but re- usage of structure ithout changing the existing one but adding ne features or characteristics to it. It is %ery much needed for any programmers in different situations. &eusability gi%es the folloing ad%antages to users It helps in reducing the code si,e since classes can be just deri%ed from existing one and one need to add only the ne features and it helps users to sa%e their time. .or instance if there is a class defined to dra different graphical figures say there is a user ho ant to dra graphical figure and also add the features of adding color to the graphical figure. In this scenario instead of defining a class to dra a graphical figure and coloring it hat the user can do is ma(e use of the existing class for draing graphical figure by deri%ing the class and add ne feature to the deri%ed class namely add the feature of adding colors to the graphical figure. Polmorphism and O!erloading: Poly refers many. *o Polymorphism as the name suggests is a certain item appearing in different forms or ays. That is ma(ing a function or operator to act in different forms depending on the place they are present is called Polymorphism. O%erloading is a (ind of polymorphism. In other ords say for instance e (no that +/ - operate on integer data type and is used to perform arithmetic additions and subtractions. 'ut operator o%erloading is one in hich e define ne operations to these operators and ma(e them operate on different data types in other ords o%erloading the existing functionality ith ne one. This is a %ery important feature of object oriented programming methodology hich extended the handling of data type and operations. Thus the abo%e gi%en important features of object oriented programming among the numerous features it ha%e gi%es the folloing ad%antages to the programming orld. The ad%antages are namely 0 "ata Protection or security of data is achie%ed by concept of data hiding 0 &educes program si,e and sa%es time by the concept of reusability hich is achie%ed by the terminology of Inheritance 0 Operators can be gi%en ne functions as per user hich extends the usage.