Chapter 1: Concept of Objects
Practice Questions
------------------------------>Objective-Type Questions<-----------------------------
A. Choose the correct answer:
1. An object is represented by two attributes, out of which one is characteristics and the other
one is ___________.
a) Behaviour b) Situation c) Abstraction d) Encapsulation
Ans. a) Behaviour
2. Name the programming technique that implements programs as an organized collection of
interactive objects.
a) Procedural Programming b) Modular Programming
c) Object-Oriented Programming d) None of these
Ans. c)Object-Oriented Programming
3. Name the characteristics of Object-Oriented Programming that hides the complexity and
provides a simple interface.
a) Encapsulation b) Polymorphism c) Abstraction d) Inheritance
Ans. c) Abstraction
4. What is the behaviour aspect of an object represented by?
a) Functions b) Data Members c) Both a and b d) None of these
Ans. a)Functions
5. What is the ability of an object to have many methods which functions differently but have the
same name?
a) Polymorphism b) Encapsulation c) Abstraction d) Inheritance
Ans. a)Polymorphism
6. Name the object-oriented technique that encompasses the parent class state and behaviours
into its child.
a) Polymorphism b) Encapsulation c) Abstraction d) Inheritance
Ans. d)Inheritance
7. Name the art of implementing encapsulation in Object-Oriented Programming.
a) Polymorphism b) Encapsulation c) Abstraction d) Class
Ans. d)class
8. What is meant by state of an object?
a) Functions of the object b) Data members of the object
c) Content of an object d) All of these
Ans. c) Content of an object
9. Name the term used to express the ability of objects to interact with each other.
a) Message Passing b) Instantiation c) Logical construct d) All of these
Ans. a)Message Passing
B. Fill in the blanks:
1. An object is an identity with certain characteristics and behaviour.
2. The values/attributes of the characteristics of an object are called the state of an object.
3. All the complexities of a program should be hidden in such a way that abstraction is obtained.
4. Class is a mechanism to implement encapsulation.
5. Objects interact with each other with the help of Message Passing.
6. A huge program divided into several individual segments is called functions/methods.
7. The objects methods/functions are said to access data.
8. A class is a logical construct and an object is a physical reality.
9. All objects have identity and are distinguishable even if the constituent components are same.
----------------------------->Subjective-Type Questions<-----------------------------
Answer the following questions:
1. Give two examples of real-world objects. Also specify their characteristics and
behaviour.
Ans. Real Life Objects
Example1:
Object Name: Pen
Characteristics: Company made, Colour, Body Shape and Nip.
Behaviour:
1) Used for writing.
2) Used for correction
3) Used for drawing or sketching
Example 2:
Object Name: Dog
Characteristics: Name, Colour and Breed.
Behaviour:
1) Barking
2) Wagging its tail
3) Running speed
2. What do you understand by state of an object? Explain with an example.
Ans. State of an object refers to the condition in which an object is in. Thus the values/attributes of its
characteristics is represented For example, a book is an object, which may be either in “open” or
“closed” state, similarly a bulb may be in switched on or switched off state.
3. How are objects implemented in Software?
Ans. Every object in real life has certain characteristics and behavior. It is the characteristic that is
represented by data variables and behaviour by methods or functions encapsulated in a class using a
software.
4. What is abstraction? How is encapsulation related to it?
Ans. Abstraction is the process of hiding the complexity and giving a simple interface and encapsulation
is the process of implementing abstraction.
Using encapsulation, the data and the code is wrapped round inside a class.
5. Define encapsulation. [ICSE 2006]
Ans. Encapsulation is the process of wrapping/combining the characteristics and behavior into a single
unit of an object to form a unique identit.
6. Explain the term object using an example. [ICSE 2006]
Ans. An object is an entity with certain characteristics and behaviour making it having its own
individuality and distinguishable. For example a pen has certain characteristics, for example its colour,
shape, size, etc. and behaviour which is used to write, sketch or draw, etc. Even though two pens are
identical with the same colour, texture, shape and size, yet they are two distinguishable pens.
7. What is a class?
Ans. A class is a method to implement encapsulation is programming. It is the class keyword in Java
that is used to wrap around the data members and member methods into a single unit. It acts as a
template that allows instances of it to be created, which are called objects.
8. What is Message Passing?
Ans. When the objects need to interact with one another, they pass or request information to or from
one another. This interaction is knows as message passing.
9. What is Object-Oriented Programming?
Ans. Object Oriented Programming is a technique of implementing programs which are organized as a
co-interactive collection of objects, each of which represents an instance of a class.
10. State the 4 characteristics/principles of Object-Oriented Programming. [ICSE 2005]
Ans. The 4 characteristics/principles of Object Oriented Programming are:
i) Abstraction
ii) Encapsulation
iii) Polymorphism
iv) Inheritance
11. Explain briefly:
a) Abstraction b) Inheritance c) Polymorphism
Ans. a) Abstraction: Abstraction refers to the art of hiding the complexities and giving a simple
interface. For example in a car, for a layman, it is good enough to know driving. Hardly will he
know the intricacies of movement of the engine, the working of the electrical and electronic
components; what he will know or will be interested with is the steering for turning, the accelerator
for speed and the switches. This is because he has been given a simple interface and the complexity
of the car engine movement has been kept completely hidden from him. Thus he doesn’t bother
about the intricacies of the car’s engine movement, but concentrates only on driving.
b) Inheritance: Inheritance is the ability to inherit characteristics from another object. In more
concrete terms, an object is able to pass on its state and behaviours to its children. For inheritance
to work, the objects need to have characteristics in common with each other. It is basically a term
that is used to represent hierarchical relationship of generalization.
c) Polymorphism: The term Polymorphism is actually a combination of two terms
Poly and Morphism. Here the term Poly means many and Morphism means forms. It is the ability of
objects to have many methods of the same name, but each one responds to different types of specific
behaviour as they have different forms.
12. How does class acts as a blueprint for an object?
Ans. A class acts as a blueprint or template that defines certain characteristics and behaviour and an
object is an instance or copy of a class.
13. How does encapsulation acts as a protective layer for an object?
Ans. Encapsulation is a technique that binds together function and the data into a single unit. You can
imagine it to be as a protective wrapper that prevents the code and data from being accessed by other
codes defined outside the wrapper.
14. How does modularity helps in reducing the complexity of a program?
Ans. Modularity helps in breaking a huge task into smaller units called functions for easy
maintainability and reusability thus reducing the complexity of the task at large.
15. What do you understand by data abstraction? Explain with an example. [ICSE 2006 & 2010]
Ans. Data abstraction refers to, providing only essential information to the outside world and hiding
their background details, i.e., to represent the needed information in program without presenting the
data.
Let's take one real life example of a TV, which you can turn on and off, change the channel, adjust the
volume, and add external components such as speakers, VCRs, and DVD players, BUT you do not know
its internal details, that is, you do not know how it receives signals over the air or through a cable, how it
translates them, and finally displays them on the screen.
16. Give a real world explanation about abstraction.
Ans. A switch board is an example of abstraction. Imagine if the concept of switchboard did not exist.
You would find a great number of wires hanging round your room. To start with an appliance, you
needed to join two wires. But essentially you need to know which group of wires should be joined to
start an appliance. Moreover, more the number of wires, more will it be confusing to identify the wires
to start an appliance. Thus joining of wires is not only confusing but may also prove fatal as far as safety
is concerned. Thus, the electrician installs a switchboard that connects each of the wires to a switch.
Hence, it is just enough to know for the user to switch on that switch that starts an appliance.
17. Why is abstraction often referred to be as relative?
Ans. Abstraction is often referred to as relative because abstraction is the selective examination of
certain aspects of a problem. The goal of abstraction is to isolate those aspects that are important for
some purpose and suppress or hide those aspects that are unimportant. Abstraction must always be for
some purpose, because the purpose determines what is important and what is not. Many different
abstractions of the same thing are possible, depending on the purpose for which they are made.