UNIT 5. Object Oriented Programming
UNIT 5. Object Oriented Programming
There are two approaches of program development. They are Procedure Oriented
Programming and Object-Oriented Programming. Procedure Oriented Programming is a
conventional method of programming and the Object-Oriented Programming is a
modern or latest programming method.
6. What are the differences between Procedure Oriented and Object Oriented
Programming?
The have the following differences: (Click here for more in detail)
b. Programs are divided into multiple modules. B. Programs are divided into multiple
objects.
Examples: FORTRAN, COBOL, Pascal, C, etc. Examples: C++, JAVA, Smalltalk, etc.
a) Object
All the entities of a program used in OOP method are called objects. Here entities
represent a group of people, teachers, students, books, cars, etc. Each entity or object
does have an attribute called characteristics and the behavior or functions. For
example, a car can be an object. The colour like blue, black, size, weight, etc. Are the
attributes or the characteristics, which distinguishes to it with other objects and move,
turn, etc. Can be the functions.
b) Class
Class is a user defined data type in OOP, which defines the data types for all the
objects, which run under it. Or it collects the objects of its similar data types. For
example, a class vehicle can have the objects like car, bus, truck, etc. Similarly a class
school can have students, teachers, staff, etc.
c) Abstraction
It is a feature of hiding internal detail of any object. It provides only the interface to the
user, which makes them easy to use but does not show the details of that object, how
that works and how that is made. Due to this feature, OOP has become very secure
platform for its data from being accidental alteration.
d) Encapsulation
It is a process of combining the data and functions together. OOP gives more emphasis
on the data rather than the functions or procedures. Many functions can use the same
data but the instruction given to the function to use any particular data and combining
them together is the encapsulation. Due to its unrelated functions cannot use
unnecessary data in the program.
e) Inheritance (Imp.)
Inheritance is the process of creating new classes based on the existing class. The new
classes require the features of the main class called the Super class and it is provided
through the feature called Inheritance. By the Inheritance feature Super class can
coordinate with it’s sub classes. It models the real world. It allows the extension and
reuse of existing code without having to rewrite for the new created classes.
f) Polymorphism
It is a feature of OOP, which refers to the way of operating the same operator in different
ways and different method or purpose. Operator overloading and the operation
overloading are the examples or Polymorphism. For example ‘+’ operator can be used
for arithmetic operation and string concatenation both. This facility or feature is an
example of Polymorphism. It reduces the number or keywords or operators.
Advantages:
b) Data is more secure due to the data hiding feature called abstraction.