0% found this document useful (0 votes)
19 views

Comp !0 ICSE CHP 3

Comp !0 ICSE CHP 3 full

Uploaded by

memeruler28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Comp !0 ICSE CHP 3

Comp !0 ICSE CHP 3 full

Uploaded by

memeruler28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CHAPTER 1

Introduction to Object Oriented Programming Concept


Section 3: Assignment Questions

1. What are programming languages? Describe the various generations of programming languages.
Ans. A Programming language is a set of commands and syntax used to create a computer program.

2. What are programming paradigms? Briefly explain two popular programming paradigms.
Ans. Programming paradigm is an approach or style of programming that is used to classify programming
language. Each programming language uses one or more programming paradigms. Each programming
paradigm supports a set of concepts that make it the best for a certain kind of problem.
The two programming paradigms are Procedure Oriented Paradigm and Object Oriented Programming.
Procedure Oriented programming paradigm is best suited for problems with step-by-step instructions
whereas, the Object Oriented Programming paradigm is the best suited for problems with a large number of
related data.

3. What are the characteristics of procedural programming?


Ans. Characteristics of procedural programming:
i. Procedural programming follows a top-down approach.
ii. The program is divided into blocks of codes called functions, where each function performs a specific task.
iii. Procedural programs model real-world processes as ‘procedures’ operating on ‘data’.
iv. The data and functions are detached from each other.
v. The data moves freely in a program.
vi. It is easy to follow the logic of a program.
vii. A function can access other function’s data by calling that function.

4. What are the limitations of procedural programming?


Ans. Limitations of procedural programming:
i. Procedural programming mainly focuses on procedures or functions. Less attention is given to the data.
ii. The data and functions are separate from each other.
iii. Global data is freely moving and is shared among various functions. Thus, it becomes difficult for
programmers to identify and fix issues in a program that originate due to incorrect data handling.
iv. Changes in data types need to be carried out manually all over the program and in the functions using the
same data type.
www.bhuvantechs.com
v. Limited and difficult code reusability.
vi. It does not model real-world entities (e.g., car, table, bank account, loan) very well where we, as a human
being, perceive everything as an object.
vii. The procedural programming approach does not work well for large and complex systems.

5. Write a short note on Object Oriented Programming.


Ans. Object Oriented Programming (OOP) is a programming paradigm which revolves around the behavior of
an object and its interactions with other objects and classes. OPP follows the design principles of Data
Abstraction, Encapsulation, Inheritance, and Polymorphism.

Introduction to Object Oriented Programming Concept ~1~


6. Explain the phrase, “Everything is an object”.
Ans. In the broadest term, everything we see around us is an object. This can be a tangible thing, such as a
car, pen, book, mobile, chair, and an ATM. Or it can be an intangible thing, such as a bank account, fee
account, an email, and an mp3 file. An object is an identifiable entity with some attributes and behaviour. For
example, we can say that a car is an object. It has attributes, such as its colour, make, model, and engine size.
Its behavior includes driving forward, backward, accelerating, and halting, etc.

7. What are the characteristics of object-oriented programming?


Ans. Characteristics of Object Oriented Programming (OOPs):
i. OOPs follows the bottom-up approach.
ii. The program resulting from object-oriented programming is a collection of objects. Each object has its own
data and a set of operations.
iii. OOPs restricts the free movement of data and the functions that operate on it. It uses a data/information
hiding technique that allows better control over data.
iv. A properly defined class can be reused, giving way to code reusability.
v. The concept of object-oriented programming models real-world entities very well.
vi. Due to its object-oriented approach, it is extremely useful in solving complex problems.

8. What are the limitations of object-oriented programming?


Ans. Limitations of Object Oriented Programming:
i. The size of the programs created using this approach may become larger than the programs written using
procedure-oriented programming approach.
ii. Software developed using this approach requires a substantial amount of pre-work and planning.
iii. OOPs code is difficult to understand if you do not have the corresponding class documentation.
iv. In certain scenarios, these programs can consume a large amount of memory.

9. What do you mean by Abstraction? Give suitable examples.


Ans. Abstraction refers to the act of representing essential features without including the background details.
For example, a building can be viewed as a single component (e.g., Hospital) rather than separate components
line cement, bricks, and rods. Abstraction is relative to the perspective of the viewer.

10. Differentiate between the Owner’s and the Vet’s perspective in the figure shown here:
Ans. Perspective of Owner is – Breed, colour, Food, and weight.
Perspective of Vet is – Vaccination, digestive health, breed and oral health.

www.bhuvantechs.com

Introduction to Object Oriented Programming Concept ~2~


11. Differentiate between the Car Mechanic’s and Car Driver’s perspective in the given figure.
Ans. Perspective of Car Mechanic – model, engine size, petrol, and transmission type.
Perspective of Car Driver – Model, Engine size, seat type, and insurance group.

12. Explain the term, Encapsulation using appropriate examples.


Ans. Encapsulation is a mechanism that binds together code and the data it manipulates; it keeps them both
safe from the outside world, preventing any unauthorised access or misuse. Only member methods, which are
wrapped inside the class, can access the data and other methods. For example, encapsulation helps to hide all
the complexity of making a call, i.e., connecting to the other device via circuitry and the mobile network.

13. Provide real-life examples to explain the term, Inheritance.


Ans. As end users of the mobile, we rely on inheritance to operate different types of mobile phones. Whether
the mobile phone is an iPhone, Samsung or Xiaomi, they all more or less operate in the same way to make a
phone call because they are all subclasses of the same super class Mobile.

14. Polymorphism means different forms. Explain Polymorphism in Java and provide examples to support
your answer.
Ans. Polymorphism is the ability of a function or an object to take on multiple forms. In OOP, polymorphism
allows an operation to exhibit different behaviours in different instances. The behaviour depends upon the
type of data used in the operation. For example, consider the operation of addition. For two numbers, the
operation will generate the sum and if the operands are strings, then the operation would produce a third
string by concatenation.

15. Write a short note on the principles of Object-Oriented Programming.


Ans. Four OOP principles are Data Abstraction, Encapsulation, Inheritance, and Polymorphism. Abstraction
refers to the act of representing essential features without including the background details. Encapsulation is
a mechanism that binds the data and code (functions) together into a single unit. Inheritance is a powerful
mechanism by which one class acquires the properties of another class and polymorphism is the ability of a
function or object to take on multiple forms. www.bhuvantechs.com

16. Explain the difference between Inheritance and Encapsulation with suitable examples.
Ans.
Encapsulation is a mechanism that binds the data and code (functions) together into a single unit. It keeps
them both safe from the outside world, preventing any unauthorised access or misuse. Take a real-life
example of a washing machine. The start button on the washing machine encapsulates lots of
complexity behind it. Here, the abstraction shows only the essential feature i.e., the Start button. The
encapsulation helps to hide all the internal details of washing, i.e., filling up the water, starting the drum,
rinsing, etc.
On the other hand, Inheritance is a powerful mechanism by which one class acquires the properties of
another class. For example, from the Birds class, specific types of birds can be inherited such as, Flying Birds.
The Flying Birds class needs to define only its own unique attributes, such as flying distance, timings of flying
and places where they fly. The rest of the generic attributes and behaviour are inherited from the Birds class.

Introduction to Object Oriented Programming Concept ~3~


17. What are the difference between Procedural Programming and Object Oriented Programming?
Ans. Difference between Procedural programming and object oriented programming:

Procedural Programming Object-Oriented Programming


Follows a top-down approach Follows a bottom-up approach
Algorithmic in nature, i.e., instruction oriented Data oriented in nature
The abstraction is at procedure (function) level The abstraction is at object (class) level
The sequence of events in a large program is divided Entire program is divided into objects.
into functions
Interaction with the program is via direct function Interaction with the program is via functions defined
calls in the class only.
Real world is represented by ‘procedures’ operating Real world is represented by objects and the
on ‘data’ operations which can be performed on these objects.
Data and functions are separate Data and functions are encapsulated into a single
entity.
Data security is less as it contains lesser features to It is more secure as one of its primary feature
protect the data. includes data hiding.
A function can access any other function’s data by Only the data whose access has been granted can be
calling that function. accessed by another function.
Limited and difficult code reusability. Versatile and easy code reusability.
Code is difficult to modify, extend, and maintain. Code is easy to modify, extend and maintain.
Examples : C, COBOL, and Pascal Examples : Java, C++ and C#

www.bhuvantechs.com

Introduction to Object Oriented Programming Concept ~4~

You might also like