Unit 1: Introduction to Object Oriented Programming Concepts
Tick the correct option
In object oriented programming, the stress is given on:
- data ✓
Which of the following principle does not allow to access directly from outside the class premises:
- data hiding
- all of the above ✓
The process of combining data and functions that enables them to be together as a single entity is called
- encapsulation ✓
The process by which a class acquires the properties from another class is called:
- inheritance ✓
In procedural programming, the stress is laid on:
- function ✓
A ............... is a set of objects that has common attributes and common behavior.
- class ✓
Which of the following is not an object oriented programming language?
- BASIC ✓
The process of restricting the free flow of data from the outside world is known as:
- encapsulation ✓
Fill in the blanks
Object is the fundamental concept in object oriented programming language.
Objects can communicate with each other through function in object oriented programming language.
Using a function for multiple operations is called as polymorphism.
Data Abstraction is an act of representing essential features without including background details.
Feature of wrapping data and functions as a single unit is called encapsulation.
Inheritance principle of object oriented programming promotes reusability feature.
Write short answers:
What is object oriented programming? Name two object oriented programming languages.
Object Oriented Programming is an approach in which stress is laid on data rather than functions. The data values remain associated with the functions of a particular block of the program so as to encourage data security. Two Object Oriented Programming languages are C++ and Java.
Name four basic principles of object oriented programming.
Four basic principles of object oriented programming are:
Why do we prefer object oriented approach in complex programming? Explain.
Object Oriented approach offers advantages like:
- Data Values are secured.
- Mishandling of data is protected.
- Error detection and correction becomes easier.
- Easier in coding complex programs.
For these reasons, Object Oriented approach is preferred for complex programming.
What is meant by a base class and a derived class?
The class that is inherited is known as base class and the class that inherits from the base is known as derived class.
Mention two limitations of procedure oriented programming approach.
Two limitations of procedure oriented programming approach are:
- No restriction on data values.
- No reusability concept hence time management, testing and length of the program increases.
What is meant by Encapsulation?
Wrapping of data and functions that operate on that data into a single unit is called Encapsulation.
Define the following with an example each.
Inheritance enables new classes to receive or inherit the properties and methods of existing classes. Example of Inheritance is given here.
In object-oriented programming, Polymorphism provides the means to perform a single action in multiple different ways. Example of Polymorphism is given here.
In what way is Data Hiding 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.
Give an example to explain Data Abstraction.
Example of Data Abstraction is given here.
What is meant by Data Hiding?
Data Hiding means restricting direct access to the implementation details of an object and providing a well defined public interface through methods to use the functionality of the object.