Q.7: How are data and functions organized in an object – oriented program?
Ans: OOP treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the function that operate on it, and protects it from accidental modification from outside functions. OOP allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects. The data of an object can be accessed only by the functions associated with that object.
Q.8: What are the unique advantages of an object – oriented programming paradigm? 
Ans:  The unique advantages of an object – oriented programming paradigm are –
i. The principle of data hiding helps the programmer to build secure programs that cannot be invaded by code in other parts of the program.
ii. It is possible to have multiple instances of an object to co-exist without any interference.
iii. It is easy to partition the work in a project based of objects.
iv. Object oriented systems can be easily upgraded from small to large systems.
v. Message passing techniques for communication between objects makes the interface descriptions with external systems much simpler.
vi. Software complexity can be easily managed.
Q.9: Distinguish between the following terms:
a. Object and classes
b. Data abstraction and data encapsulation
c. Inheritance and polymorphism
d. Dynamic binding and message passing
Ans: (a) Object: Objects are the basic runtime entities in an object oriented programming. An object is an instance of a class. It can be uniquely identified by its name and it defines a state which is represented by the values of its attributes at a particular time.
The state of the object changes according to the methods which are applied to it. We refer to these possible sequences of state changes as the behavior of the object.   
Class: A class is the implementation of an abstract data type (ADT). It defines attributes and methods which implement the data structure and operations of the ADT, respectively. Instances of classes are called objects. Consequently classes define properties and behaviors of sets of object. Thus a class is a collection of objects of similar type and objects are variables of the type class.  
(b) Data abstraction: Abstraction refers to the act representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes. 
Data encapsulation: The wrapping up of data and functions into a single unit is known as encapsulation. The data is not accessible to the outside world and only those functions which are wrapped in the class can access it. These functions provide the interface between the objects data and the program. This insulation of the data from direct access by the program is called data hiding or information hiding. As a result data become secured. Thus the encapsulation reduces complexity. 
(c) Inheritance: Inheritance is the process by which objects of one class acquire the properties of objects of another class. 
Inheritance is the mechanism which allows a class A to inherit properties of a class B. We say ``A inherits from B''. Objects of class A thus have access to attributes and methods of class B without the need to redefine them. 
The concept of inheritance provides the idea of reusability. This means that we can add additional features to an existence class without modifying it.
Polymorphism: Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behaviors depend upon the types and number of data used in the operation. The process of making an operator exhibit different behaviors in different instances is known as operator overloading. 
(d) Dynamic binding: Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding / late binding means that the code associated with a given procedure call is not known until the time of the call of the run time. It is associated with polymorphism and inheritance.
Message passing: A message for an object is a request for execution of a procedure and therefore will invoke a function in the receiving object that generates the desired result. Message passing involves specifying the name of the object, the name of the function and the information to be sent.
Example:
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment