Object Oriented Programming (OOP)
1. What is object oriented
program? Write its characteristics.
Object oriented programming is a programming paradigm
(model) that was developed to overcome the drawbacks and limitations of
particularly procedure oriented programming. The major need for developing such
languages was to manage the ever-increasing size and complexity of programs.
Characteristics:
a. Emphasis
is on data rather than procedure.
b. Programs
are divided into objects.
c. Data
structures are designed such that they characterize the objects.
d. Functions
that separate on the data of an object are tied together in the data structure.
e. Data
is hidden and cannot be accessed by external functions.
f. Objects
may communicate with each other through functions.
g. New
data and functions can be easily added whenever necessary.
h. Bottom-up
approach is followed in program design.
2. What are the advantages and
disadvantages of OOP?
Advantages of
OOP:
a. We
can eliminate redundant codes by using inheritance feature of OOP.
b. It
is very easy for managing complex and large size problems.
c. The
most important is the reusability of codes by using the features inheritance.
d. It
takes very less time for the development and maintaining the software.
e. It
is efficient for testing and implementation of the system.
f. It
follows bottom up approach.
g. It
can be implemented in the field of OODBMS, OOAD and different fields of
engineering.
Object Oriented Programming has
several disadvantages which made it unpopular in the early
years.
a.
Size: Object oriented programs are much larger
than other programs.
In the early days of computing,
space on hard drives, floppy drives and in memory was at a premium.
Today we do
not have these restrictions.
b.
Effort: Object oriented programs require a lot
of work to create.
Specifically, a great deal of
planning goes into an object oriented program well before a single piece
of
code is ever written. Initially, this early effort was felt by many to be a
waste of time. In addition,
because the programs were larger (see above) coders
spent more time actually writing the program.
c.
Speed: Object oriented programs are slower than
other programs, partially because of their size. Other
aspects of Object Oriented Programs also demand more system resources, thus
slowing the program down.
3. Define
inheritance and polymorphism.
The process of creating a new class form an existing
class in which objects of the new class inherit the attributes and behaviors of
the existing class is known as inheritance. The newly created class is called
derived class or child class and the class from which new class is derived is
called base class or parent class. It permits the expansion and reuse of
existing code without rewriting it hence, the concept of inheritance supports
the concept of reusability.
The meaning of polymorphism is having many forms. It is
an important feature of OOP which refers to the ability of an object to take on
different forms depending upon situations. It simplifies coding and reduces the
rework involved in modifying and developing an application.
4. What are
the differences between OOP and POP?
OOP
|
POP(procedure oriented program)
|
Focuses on objects and
their behavior
|
Focuses on logical
structure
|
Large programs are
divided into objects
|
Large programs are
divided into functions
|
Data and functions are
tied together so they cannot move freely
|
Data move openly around
the system from function to function
|
Uses bottom up approach
|
Uses top down approach
|
Consists features of
data abstraction, encapsulation, inheritance and polymorphism
|
Does not have any that
features
|
Developing is quite
easier and faster
|
Developing is difficult
and time consuming
|
Provides high level of
security
|
Security cannot be
maintained
|
New data and functions
can be easily added
|
Difficult to add new
functions
|
Reuse of code can be
implemented
|
Code reusability is
difficult to maintain
|
Example: C++, java,
.net, etc
|
Example: C, Pascal,
FORTRAN, etc
|
5. Define
the following terms:
a. Object: An object is any entity, thing or organization
that exits in real world. It consists of two fundamentals characteristics: its
attributes and behaviors. For example: a dog is an object having attributes
such as color, weight, age, etc. and behaviors such as barking, wagging tail,
etc. In OOP, attributes are represented by data and behaviors are represented
by functions.
b. Class: A class is the collection of similar objects.
It is defined as the template or prototype to define the common attributes and
behavior for all the objects of the class. The entire set of data and code of
an object can be made a user-defined data type with the help of a class. In
fact objects are variables of type class. Once, a class has been defined,, we
can create any number of objects associated with that class.
c. Data abstraction: In OOP, data abstraction defines the
conceptual boundaries of an object. These boundaries distinguish an object from
another object. So, abstraction is the act of representing essential features
without including the background details. It focuses the outside view of an
object, separating its essential behavior from its implementation.
d. Encapsulation: Encapsulation is a way if organizing
data and function into a structure by concealing the way the object is implemented,
that is preventing access to data by any means other than those specified.
Encapsulation therefore guarantees the integrity of the data contained in the
object. It implies that there is visibility to the functionalities offered by
an object, and no visibility to its data.
0 comments:
Post a Comment