Chapter 6 : Basic Concepts of OOP
Object Oriented Programming (OOP):is a programming paradigm that uses objects to design applications &
computer programs.
Examples of OOP Languages: C++, Java, C#, PHP, Perl etc.
The OOP method uses data as the main element in the program. The data is tied to the function that operates on
the data & other functions cannot modify the data tied to a given function.
Data Data
Function Function
Data
Function
Fig: Organization of Data & Functions in OOP.
Basic Concepts(Techniques) of OOP (Characteristics of OOP)
Objects
Classes
Data Abstraction
Data Encapsulation
Inheritance
Overloading
Polymorphism
Dynamic binding
Message passing
Object : is an instance of a class.
It is a basic run time entity with some characteristics & behavior. These are the basic building blocks for
designing programs. An object may represent a person, place or table of data.
Objects take up space in memory. The object can be represented as:
Member Data
Name
Regno
Course
Member Function
Getdata()
Display()
Class: is a user defined data type that contains data members & member functions.
A class describes a group of objects with similar characteristics. In fact, objects are variables of type
class. Once a class is defined any number of objects of that class can be created.
For ex: Planets, Sun, Moon are members of the class Solar System.
Data abstraction:
Abstraction is the process of representing essential features without including background details.
Data abstraction permits the user to use an object without knowing its internal working.
Data encapsulation:
Encapsulation is the mechanism that combines data & function into a single unit called as class.
The concept of insulating the data from direct access by the program is called Data hiding (Information hiding).
Fig: Encapsulation of data
Inheritance:
Inheritance is the process of forming a new class from an existing class.
The existing class is known as base class or super class & the new class is known as derived class or sub class.
Super Class
Sub Class-1 Sub Class-2
Fig: Base & Derived class
The objects of one class acquire the properties of another class through inheritance.
Overloading:
Overloading allows objects to have different meaning depending upon context.
There are 2 types:
1) Operator Overloading When an existing operator operates on new data type, It is called operator overloading.
2) Function Overloading: means 2 or more functions having same name, but differ in the number or data type of
arguments.
Polymorphism:
The ability of an operator or function to take multiple forms is known as polymorphism.
Dynamic Binding
Dynamic Binding means that the code associated with a given procedure call is known only at run time.
Message Passing
Message passing is a technique for communication between objects. Objects communicate with one another by
sending & receiving information.
Message passing involves specifying name of the object, name of function (message) & the information to be sent.
For ex:student.mark(name)
Object Message Information
Advantages of OOP over earlier Programming methods
The programs are modularized using classes & objects.
OOPS reduces code duplication.
Providing data security with data encapsulation.
Easier to develop complex software with inheritance.
Data abstraction separates object specification & object implementation.
Allows code reusability by linking code & object.
Reduces software development time.
Communication with outside system is very simple with message passing.
Disadvantages or Limitations of OOP
There are no set standards for OOP.
The classes are overly generalized.
To convert real life problem into OOP is difficult.
Difficult to adapt flow diagrams.
Applications of OOP
The common application areas of OOP are:
Computer graphic applications.
CAD/CAM Software.
Object Oriented Database.
User Interface design Such as windows.
Real Time systems.
Simulation & Modeling.
Artificial Intelligence & expert system.