Chapter 4 Unit 1: Object Oriented Programming
Fill in the blanks with appropriate word/words
In procedural programming, the stress is on functions.
Object is a unique entity that occurs in object oriented programming.
The process of combining data and functions that are used together as a unit is called Encapsulation.
The process by which an object acquires some properties from another is Inheritance.
In Object Oriented Programming, the stress is put on data.
The process of restricting the free flow of data from the outside world is known as Encapsulation.
State true or false
The prime task in procedure-oriented programming language is to create object.
Using a function for multipurpose applications, is called an Abstraction.
Object is the fundamental concept of object-oriented language.
Abstraction promotes data hiding facilities.
Encapsulated class can have the feature of re-usability.
Inheritance promotes the inter class sharing of data.
Objects can communicate with each other through functions.
Once an object is created, it means the data can be accessed outside the object.
Encapsulation promotes data sharing among the objects.
Write short answers
What do you understand by Object Oriented Programming? Name two OOP languages.
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:
Name any two OOP's principles.
Two OOP's principles are:
What are the features of OOP?
Features of Object Oriented Programming are:
- It gives stress on the data items rather than functions.
- It makes the complete program/problem simpler by dividing into number of objects.
- The objects share information through functions.
- Data remain secure from outer interference.
Define the following:
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.
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.
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
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.
Write two disadvantages of Procedure Oriented Programming.
- 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.
- It is not suitable to solve complex problems in real situation.
How can 'Data Abstraction' be made useful in the real world? Explain with an example.
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.
What are the benefits of OOP?
- An existing class can be extended through Inheritance.
- Data hiding enables writing secured programs.
- Multiple instances of an object can be generated to co-exist without any interference.
- Different modules can be created in the project using objects.
- It is highly beneficial in solving complex problems.
- OOP makes it easier to modify and maintain software complexity.
TV set is a real world object. How?
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:
|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.
In what way Data Hiding is related to Data Abstraction?
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.
Explain Polymorphism with an example.
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.
Differentiate Encapsulation and Inheritance.
|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.|