Chapter 4 Unit 1: Object Oriented Programming

PrevNextBack

Chapter 4 Unit 1: Object Oriented Programming

Contents

Fill in the blanks with appropriate word/words

Question 1

In procedural programming, the stress is on functions.

Question 2

Object is a unique entity that occurs in object oriented programming.

Question 3

The process of combining data and functions that are used together as a unit is called Encapsulation.

Question 4

The process by which an object acquires some properties from another is Inheritance.

Question 5

In Object Oriented Programming, the stress is put on data.

Question 6

The process of restricting the free flow of data from the outside world is known as Encapsulation.

State true or false

Question 1

The prime task in procedure-oriented programming language is to create object.
False

Question 2

Using a function for multipurpose applications, is called an Abstraction.
False

Question 3

Object is the fundamental concept of object-oriented language.
True

Question 4

Abstraction promotes data hiding facilities.
True

Question 5

Encapsulated class can have the feature of re-usability.
False

Question 6

Inheritance promotes the inter class sharing of data.
True

Question 7

Objects can communicate with each other through functions.
True

Question 8

Once an object is created, it means the data can be accessed outside the object.
False

Question 9

Encapsulation promotes data sharing among the objects.
False

Write short answers

Question 1

What do you understand by Object Oriented Programming? Name two OOP languages.

Answer

Object Oriented Programming is a modular approach of programming that gives stress to data over functions. It decomposes the program into a number of entities called Objects. Each Object contains data and functions to operate on that data. Objects cannot access each other's data, they only communicate through functions.

Two OOP languages are:

  1. Java
  2. C++

Question 2

Name any two OOP's principles.

Answer

Two OOP's principles are:

  1. Abstraction
  2. Encapsulation

Question 3

What are the features of OOP?

Answer

Features of Object Oriented Programming are:

  1. It gives stress on the data items rather than functions.
  2. It makes the complete program/problem simpler by dividing into number of objects.
  3. The objects share information through functions.
  4. Data remain secure from outer interference.

Question 4

Define the following:

(a) Inheritance

Answer

Inheritance enables new classes to receive or inherit the properties and methods of existing classes. The class that acquires the properties is called the child class or sub-class or target whereas the class that gets inherited to another class is called the base class or super class.

(b) Polymorphism

Answer

Polymorphism is the process of using a function for more than one purposes. It allows the use of different internal structure of the object by keeping the same external interface.

(c) Encapsulation

Answer

The system of wrapping of data and functions of an object together as a unit in such a way that the data items are accessible only within the functions of the same object is known as Encapsulation.

(d) Data Hiding

Answer

The process of isolating the data such that it cannot be accessed directly outside the class premises although they are available in the same program is known as Data Hiding.

Question 5

Write two disadvantages of Procedure Oriented Programming.

Answer

  1. As data values are global to all the functions, you may be required to make necessary changes in the function due to any change in the data values.
  2. It is not suitable to solve complex problems in real situation.

Question 6

How can 'Data Abstraction' be made useful in the real world? Explain with an example.

Answer

Electrical switchboard is an example of Data Abstraction in real world. To switch on or off a particular light or fan, we press the required switch to on or off position. We don't worry about the things like how the the circuit is affected by the switch, what is the internal wiring, etc. Switchboard hides all such background details from us and provides a very simple way to operate the lights, fans and other electrical appliances.

Question 7

What are the benefits of OOP?

Answer

  1. An existing class can be extended through Inheritance.
  2. Data hiding enables writing secured programs.
  3. Multiple instances of an object can be generated to co-exist without any interference.
  4. Different modules can be created in the project using objects.
  5. It is highly beneficial in solving complex problems.
  6. OOP makes it easier to modify and maintain software complexity.

Question 8

TV set is a real world object. How?

Answer

A real world object is an entity having a specific identity, specific characteristics and specific behavior. A television can be considered as an object that posses the following characteristics and behaviours:

CharacteristicsBehaviours
It is rectangular in shape.It is used to view news.
It has a flat screen.It is also used to watch games.
It contains a number of channels.It is used to view different entertainment channels.

Moreover a television set is owned by someone giving it an identity. Hence, television set is a real world object.

Question 9

In what way Data Hiding is related to Data Abstraction?

Answer

Data Hiding and Data Abstraction are complementary concepts. Data Abstraction focuses on the observable behaviour of an object, whereas Data hiding or Data Encapsulation focuses upon the implementation that gives rise to this behaviour. In other words, Data Abstraction cares about what something does but not how it does it. Data Encapsulation cares about how something does what it does such that others don't have to worry about the implementation details. Hence, we can say that Encapsulation is a way to implement Data Abstraction.

Question 10

Explain Polymorphism with an example.

Answer

In object-oriented programming, Polymorphism provides the means to perform a single action in multiple different ways. Taking the real world example of animals, if we ask different animals to speak, they respond in their own way. Dog barks, duck quacks, cat says meow and so on. So the same action of speaking is performed in different ways by different animals.

Question 11

Differentiate Encapsulation and Inheritance.

Answer

EncapsulationInheritance
Encapsulation binds the data and the functions that operate on that data into a single unit.Inheritance enables new classes to receive or inherit the properties and methods of existing classes.
It supports Data Hiding.It supports code reusability.
It keeps data safe from outside interference.It allows us to do hierarchical classification of data.