UNIT 5. Object
Oriented Programming (3 marks)
1. What are the
programming methods or approaches of program development?
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.
2. What is
Procedure Oriented Programming?
It is a
conventional or old method of programming, in which the program is written into
many small parts and combined together. In this approach, the functions are
created and the data is not very crucial. Variables are created for the data
handling and they are treated as the global and local variables. Creation of
the variables inside of the sub programs is known as local variable and the
creation of the variables in the main module is called the global variable.
Global variables can be accessed from any modules but the local variables can
be accessed only within the local modules. The alteration of data is very high.
3. What are the
features of Procedure Oriented Programming?
The characteristics
or features are as follow:
a) A large
program is broken down into small programs or procedures.
b) It focuses
on the functions rather than the data.
c) Variables
are created as local and global.
d) The
possibility of data alteration is very high, which is the main disadvantage of
this approach.
e) It follows
top down method.
4. What is
Object Oriented Programming?
It is a modern
approach of programming. It is highly known as OOP in short form. In this
method, all the real world entities are treated as the objects and objects are
collected in a class. Even the classes are controlled by the Super class. And
by the inheritance feature, the changes on the super class are easily passed to
its sub classes. Similarly, it was developed to overcome procedure oriented
programming method and the data is given high priority rather than the
functions. Data can be hidden, so that the possibility of data alteration is
very less.
5. What are the
characteristics of OOP?
The
characteristics of OOP are:
a) Emphasis is
given to the data.
b) Program are
divided into multiple objects.
c) Functions
and data are tied together in a single unit.
d) Data can be
hidden to prevent accidental alteration.
e) It follows
the bottom up approach.
6. What are the
differences between Procedure Oriented and Object Oriented Programming?
The have the
following differences:
Procedure Oriented Object Oriented
a. Emphasis is
given to procedures. a. Emphasis
is given to data.
b. Programs are
divided into multiple modules. b.
Programs are divided into multiple objects.
c. It follows
top-down method. c. It follows bottom-up
method.
d. Generally
data cannot be hidden. d. Data can
be hidden.
e. It does not
model the real world perfectly. e. It
models the real world perfectly.
f. Maintenance
is difficult. f. Maintenance is
easy.
g. Code
reusability is difficult. g. Code
reusability is easy.
Examples:
FORTRAN, COBOL, Pascal, C, etc. Examples:
C++, JAVA, Smalltalk, etc.
7. Write short
notes on the following:
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.
8. What are the
advantages and disadvantages of OOP? (most imp)
Advantages:
a) Code
repetition is reduced by the various techniques like inheritance.
b) Data is more
secure due to the data hiding feature called abstraction.
c) Existing
classes can serve as library class for further enhancements.
d) Division of
a program into multiple objects makes the software development easier.
e) Software
complexity is less.
f) Upgrading
and maintenance of software is easy.
g) It perfectly
models the real world system.
h) Code
reusability is much easier than the conventional programming system.
Disadvantages
a) Compiler and
runtime overhead is high.
b) Software
developer should analyze the problem in object oriented way.
c) Requires the
mastery in software engineering and programming methodology.
d) Useful only
for the large and complex projects.
No comments:
Post a Comment