KnowledgeBoat Logo

Chapter 1

Introduction to Object Oriented Programming Concepts

Class 9 - Logix Kips ICSE Computer Applications with BlueJ


Multiple Choice Questions

Question 1

Procedure Oriented Programming gives importance to ...........

  1. Instructions only ✓
  2. Instructions and data
  3. Data only
  4. None of these

Explanation

As Procedure Oriented Programming follows Top-down approach so the focus is on the steps or instructions to solve a problem.

Question 2

Procedure Oriented Programming mainly uses ...........

  1. Top-down approach ✓
  2. Top-down and bottom-up approach
  3. Bottom-up approach
  4. None of these

Explanation

In Top-down approach, we first list down the main steps involved in solving a problem. After that we break up each of those steps into their sub-steps and so on. This is similar to Procedure Oriented Programming where we first write a main function and then call sub-functions from the main function to perform each of these steps.

Question 3

Object Oriented Programming mainly uses ...........

  1. Top-down approach
  2. Top-down and bottom-up approach
  3. Bottom-up approach ✓
  4. None of these

Explanation

In Bottom-up approach to programming, the smallest individual parts of the system are first identified and specified in detail. These individual parts are then linked together to form larger and larger components until the entire program is ready. Object Oriented Programming follows bottom-up approach because in OOP we first identify the smallest parts of the program i.e. the objects. We then combine these objects to develop the complete program.

Question 4

An object belonging to a particular class is known as a/an ........... of that class.

  1. Interface
  2. Instance ✓
  3. Alias
  4. Member

Explanation

The terms object and instance are often interchangeable.

Question 5

Objects that share the same attributes and behaviour are grouped together into a/an ...........

  1. Interface
  2. Instance
  3. Alias
  4. Class ✓

Explanation

A class is a template or blueprint for multiple objects with similar features and maybe regarded as a specification for creating similar objects.

Question 6

........... is the technique of binding both data and functions together to keep them safe from unauthorised access and misuse.

  1. Abstraction
  2. Inheritance
  3. Encapsulation ✓
  4. Polymorphism

Explanation

This is the definition of Encapsulation.

Question 7

........... refers to the act of representing essential features without including the background details.

  1. Abstraction ✓
  2. Inheritance
  3. Encapsulation
  4. Polymorphism

Explanation

This is the definition of Abstraction.

Question 8

........... is the feature by means of which one class acquires the properties of another class.

  1. Abstraction
  2. Inheritance ✓
  3. Encapsulation
  4. Polymorphism

Explanation

This is the definition of Inheritance.

Question 9

The ability of a function or object to take on multiple forms is called ...........

  1. Abstraction
  2. Inheritance
  3. Encapsulation
  4. Polymorphism ✓

Explanation

This is the definition of Polymorphism.

Question 10

The term OOP stands for

  1. Object Oriented Procedure
  2. Object Oriented Packet
  3. Object Oriented Programming ✓
  4. Object Orientation Procedure

Explanation

Short form of Object Oriented Programming is OOP

State whether the given statements are True or False

Question 1

Low-level languages are closer to computer hardware.
True

Question 2

In a procedural language, code and data are held separately.
True

Question 3

In object-oriented programming, code and data are held separately.
False

Question 4

Wrapping up data and related functions in a single unit represents encapsulation.
True

Question 5

The object is also known as an instance.
True

Question 6

The class that is derived from another class is called a superclass.
False

Question 7

Classes can be derived from other classes.
True

Question 8

Inheritance allows a class to acquire the properties of another class.
True

Question 9

A class is a blueprint for the attributes and behaviours of a group of objects.
True

Question 10

Objects from the same class do not share the same definition of attributes and behaviours.
False

Assignment Questions

Question 1

What are programming languages? Describe the various generations of programming languages.

Answer

A Programming Language is a set of commands and syntax used to create a computer program. The various generations of programming languages are:

  1. First Generation Programming Language — Machine language is the first-generation programming language (1GL). It is made up of binary number 0 (Zero) and 1 (One) so instructions in Machine language are sequences of zeros and ones. It is a low-level language.
  2. Second Generation Programming Language — Assembly language is second-generation language (2GL). It uses symbolic operations called mnemonics instead of binary digits that can have up to maximum of five letters. Assembly language is also a low-level language.
  3. Third Generation Programming Language — A third-generation language (3GL) is close to English in vocabulary. These languages are easier to read and require less time to write programs. Third-generation programming languages are high-level programming languages, such as FORTRAN, Java, C, and C++.
  4. Fourth Generation Programming Language — A fourth-generation language (4GL) is closer to a natural language (for example, English) than a third- generation language. These languages are non-procedural. It means that the programmer specifies what is required as opposed to how it is to be done. Database languages such as Structured Query Language (SQL), report generators such as Oracle Reports, and Python are examples of fourth-generation languages.
  5. Fifth Generation Programming Language — A fifth-generation language (5GL) is designed to solve a given problem using constraints given to the program, rather than using an algorithm written by a programmer. The fifth-generation languages are mainly used in Artificial Intelligence. Smalltalk, Prolog, and Mercury are good examples of the fifth-generation languages.

Question 2

What are programming paradigms? Briefly explain two popular programming paradigms.

Answer

A programming paradigm is an approach or style of programming that is used to classify programming languages. Each programming language uses one or more programming paradigms. Two popular programming paradigms are:

  1. Procedure Oriented Programming — In this programming paradigm, a complex programming problem is solved by dividing it into smaller problems using functions (or procedures).
  2. Object Oriented Programming — In this programming paradigm, data and functions are wrapped into a single unit.

Question 3

What are the characteristics of procedural programming?

Answer

The characteristics of procedural programming are:

  1. Procedural programming follows a top-down approach.
  2. The program is divided into blocks of codes called functions, where each function performs a specific task.
  3. Procedural programs model real-world processes as 'procedures' operating on 'data'.
  4. The data and functions are detached from each other.
  5. The data moves freely in a program.
  6. It is easy to follow the logic of a program.
  7. A function can access other function's data by calling that function.

Question 4

What are the limitations of procedural programming?

Answer

The limitations of procedural programming are:

  1. Procedural programming mainly focuses on procedures or functions. Less attention is given to the data.
  2. The data and functions are separate from each other.
  3. 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.
  4. Changes in data types need to be carried out manually all over the program and in the functions using the same data type.
  5. Limited and difficult code reusability.
  6. 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.
  7. The procedural programming approach does not work well for large and complex systems.

Question 5

Write a short note on Object Oriented Programming.

Answer

Object Oriented Programming (OOP) is a programming paradigm which revolves around the behaviour of an object, and its interactions with other objects and classes. In OOP, the program is organised around data or objects rather than functions or procedures. It follows the design principles of Data Abstraction, Encapsulation, Inheritance, and Polymorphism.

Question 6

Explain the phrase, "Everything is an object".

Answer

The world around us is made up of objects such as people, vehicles, buildings, streets, mobiles, television, etc. Each of these objects has the ability to perform specific actions and each of these actions influences the other objects in some way or the other. The objects around us can be divided into the following categories:

  1. Tangible Objects — These are the objects that we can see and touch. For example, chair, pen, book, door, etc.

  2. Conceptual Objects — These objects exists as a conceptual entity that we cannot touch. We may or may not be able to see them. For example, an email, a bank account, a song, patents, etc.

  3. Roles — Roles played by people, such as a student, a teacher or a clerk.

  4. Events — An event is something occurring in a system or an organisation. For example, a sale or a purchase in a departmental store, someone's birthday, etc.

Question 7

What are the characteristics of object-oriented programming?

Answer

The characteristics of object-oriented programming are:

  1. It follows a bottom-up approach.
  2. The program resulting from object-oriented programming is a collection of objects. Each object has its own data and a set of operations.
  3. OOP restricts the free movement of data and the functions that operate on it.
  4. A properly defined class can be reused, giving way to code reusability.
  5. The concept of object-oriented programming models real-world entities very well.
  6. Due to its object-oriented approach, it is extremely useful in solving complex problems.

Question 8

What are the limitations of object-oriented programming?

Answer

Limitations of object-oriented programming:

  1. The size of the programs created using this approach may become larger than the programs written using procedure-oriented programming approach.
  2. Software developed using this approach requires a substantial amount of pre-work and planning.
  3. OOP code is difficult to understand if you do not have the corresponding class documentation.
  4. In certain scenarios, these programs can consume a large amount of memory.

Question 9

What do you mean by Abstraction? Give suitable examples.

Answer

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 like cement, bricks, and rods. Abstraction is relative to the perspective of the viewer.

Question 10

Differentiate between the Owner's and the Vet's perspective in Figure 1.24

ICSE Logix class 10 solutions Vehicle class hierarchy as example of Inheritance

Answer

From the viewpoint of the dog's owner, the things that are essential for the dog are his favorite food, the colour of his food bowl, his favorite game that he enjoys playing with his owner, his preferred time for walk, etc. From the viewpoint of the dog's vet (doctor for animals), the important things about the dog are whether the dog's body functions are normal or not to ensure that the dog is healthy. Like this, there can be two abstractions for the dog — one for the dog's owner and the other for the dog's vet.

Question 11

Differentiate between the Car Mechanic's and Car Driver's perspective in Figure 1.25

ICSE Logix class 10 solutions Vehicle class hierarchy as example of Inheritance

Answer

From the viewpoint of the driver, a car is one single object. It can be operated using gears, indicators, accelerator, brake, etc. The driver doesn't need to know or understand the internal mechanisms of how these components actually work. From the viewpoint of the mechanic, it is important for him to understand how the internal mechanisms like gears, indicators, accelerator, brake, etc. actually work so that they can identify and fix issues with the cars. For a mechanic, each car part is a single object.

Question 12

Explain the term Encapsulation using appropriate examples.

Answer

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, an ATM contains different denominations of currency notes and it provides a set operations to the user to withdraw money. The different denominations of currency notes is the data, the set of operations are the methods and the ATM encapsulates them into a single unit enabling us to withdraw cash conveniently.

Question 13

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

Answer

To explain Inheritance, let's take the example of traffic on the road. This traffic has some commonalities. It consists of things that can move on the road and transport people and goods from one place to another. We call these things vehicles. These vehicles differ from each other in certain aspects like whether it transports passengers or goods, how many passengers it can accommodate at a time, whether it is a two-wheeler or four-wheeler, etc. So, we have different types of vehicles like Cars, Bikes, Scooters, Auto rickshaw, Buses, Trucks, etc. We can represent this traffic using Inheritance as shown below. Here, Vehicle is the base class having the common characteristics and behaviours of all Vehicles. Then we have Car, Bike, Bus, Truck as subclasses of Vehicles.

ICSE Logix class 10 solutions Vehicle class hierarchy as example of Inheritance

Question 14

Polymorphism means different forms. Explain Polymorphism in Java and provide examples to support your answer.

Answer

Polymorphism is the ability of a method or an object to take on multiple forms. In OOP, polymorphism allows an operation to exhibit different behaviour 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 a sum. If the operands are strings, then the operation would produce a third string by concatenation.

Question 15

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

Answer

There are four principles of Object Oriented Programming:

  1. Data Abstraction — It refers to the act of representing essential features without including the background details.
  2. Encapsulation — It is a mechanism that binds the data and code (functions) together into a single unit.
  3. Inheritance — It is a powerful mechanism by which one class acquires the properties of another class.
  4. Polymorphism — It is the ability of a function or object to take on multiple forms.

Question 16

Explain the difference between Inheritance and Encapsulation with suitable examples.

Answer

Encapsulation is a mechanism that binds together code and the data it manipulates whereas Inheritance is the mechanism by which a class acquires the properties and methods of another class. An ATM binding together the different denominations of currency notes and all the operations required to withdraw cash is an example of Encapsulation. Classifying Vehicles as Car, Bike, Bus, Truck, etc. is an example of Inheritance.

Question 17

What are the differences between Procedural Programming and Object-oriented Programming?

Answer

Procedural ProgrammingObject-Oriented Programming
Follows a top-down approachFollows a bottom-up approach
Instruction OrientedData Oriented
The abstraction is at procedure (function) level.The abstraction is at object (class) level.
The sequence of events in a large program is divided into functions.Entire program is divided into objects.
Interaction with program is via direct function calls.Interaction with program is via functions defined in the class only.
Real world is represented by 'procedures' operating on data.Real world is represented by objects and the operations that can be performed on these objects.
Data and functions are separate.Data and functions are encapsulated into a single unit.
Data security is less as it contains lesser features to protect the data.It is more secure as one of its primary features include data hiding.
A function can access any other function's data by calling that function.Only the data whose access has been granted can be 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.
Some examples of Procedural Programming languages are C, COBOL, Pascal.Some examples of Object Oriented languages are C++, Java, C#.

Video Explanations

PrevNext