You are on page 1of 2

Question

Chapter 04: What is Object-Orientation?

Question 1
What is abstraction? What is an object? Write two main purposes of objects.
Answer:
The act of separating out the general or reusable parts of an element of a system from its particular implementation is abstraction.

An object is an abstraction of something in a problem domain, reflecting the capabilities of the system to
– keep information about it,
– interact with it,
– Or both.
Object: An object is an instance of a class or a member of a class that defines a set of similar objects. In software
world, an object is a concept that can be represented as an encapsulation of state, behaviour and identity.
Objects are used two main purposes:
1. To model an understanding of the application domain
2. To form parts of the resulting software of development activities

Question 2
What features do all objects have?
All objects have three features.
1) State: State represents the particular condition of an object in at a given moment.
2) Behaviour: Behaviour stands for the things that the object can do.
3) Identity: Identity makes an object identifiable and unique among all other objects.

Question 3

Differentiate class and instance:


Class: A class is a descriptor for a collection of objects that are logically similar in terms of their behavior
and the structure of their data. A class is blueprint for a group of a set of similar objects. All objects of a class are
structured according to the class and behave according to its class.
Instance: An instance is a single object that originates from a class. It is structured and behaves according
to its class.

Question 4
How can test whether two object belong to the same class?
Answer:
There are two types of logical similarities among two objects of the same class and these two similarities must be tested.
1. Tow objects of the same class a common set of descriptive chrematistics i.e, two objects for a class holds same
information structure.
2. Tow objects of the same class share a common set of behaviors

Question 5
What do you mean by ‘semantics’?
Answer:
Semantics is the study of meaning. In object-oriented development it is used to denote the meaning that an has for the user. The
semantics of an object include its purpose, description, relationships and behaviour seen from a user perspective.

Question 6
Explain Generalization and Specialization? (Difference)

Generalization: Generalization is a taxonomic relationship between a more general element and a more
specific element. It is the abstraction of common feature among elements by the creation of a hierarchy of more
general elements that encapsulate common features. (For example, in animal world a cat and a dog share some common features and we
create a common general class “Mammal” which encapsulates common their common feature. A cat, a dog – both are consistent with mammal class. )
Specialization: Specialization is the other face of generalization. A class is said to be specialized when it
has a set of characteristics that uniquely distinguish it from its super class. (For example, a cat is a mammal but it is more specialized
than a mammal, it can hunt at night but form a mammal this fact is not true. )

Question 7
What is inheritance? Write down the rules of inheritance.
Inheritance: The mechanism by which object-oriented languages implement a relationship of
generalization and specialization between classes is called inheritance. When we extend a class from an existing
class – the existing class is the superclass and the extended class is subclass. A sub class automatically acquires
features of its superclass.
The rules of inheritance:
1) A subclass always inherits all the characteristics of its superclass.
2) The definition of a subclass always includes at least one detail not derived from any of its super
classes.

1
Question 8
What is message-passing?
Answer:
It is a metaphor for the way that objects interact in object-oriented system by sending each other messages that request services
or supply information. In a system, sseveral objects may collaborate to fulfil an action. These objects communicate by sending
each other message. Since objects interact only through messages they exchange, their internal detail can remain hidden from
each other.

Question 9
Explain transitive operation and disjoint nature of generalization.
Answer:
Transitive operation: This means that the relationship between elements of two adjacent levels of a hierarchy carries over to all
more specialized levels. If we create a class B from A and further more if we create a class C from B, C inherits all the features
from B and also from A.
Disjoint nature: In simplest form, a class can inherit from only one superclass. A cat can not be both a mammal and a reptile.

Question 10
What are an operation and an operation signature?
Answer:
Operation: An operation is a service that is provided by a class. In other word, an operation is a functionality that will be
implemented as a method of an object. An object encapsulates data and operations process, act on that data. Other objects
request for a service and an operation is invoked.
Operation signature: Every operation has a signature and to request an operation on an object, the operation signature must be
known. An operation signature is a definition of its interface. An operation signature is determined by the operation’s name, the
number and the type of its parameters and the type of its return value.

Question 11
Explain polymorphism.

Polymorphism: Changing the behaviour of the methods of the inherited class is called polymorphism. It
means the ability of different methods to implement the same operation, and thus to respond to the same message
in different ways that are appropriate to its class.

Question 12
Write down some advantages of object orientation.
Answer:
Advantages of O-O:
 Can save effort
 Reuse of generalized components cuts work, cost and time
 Can improve software quality
 Encapsulation increases modularity
 Sub-systems less coupled to each other
 Better translations between analysis and design models and working code

Question 13
Explain encapsulation.

Encapsulation: Protecting some data members by hiding the implementation and exposing the interface is
called encapsulation.

You might also like