0% found this document useful (0 votes)
83 views10 pages

Chapter 13 - Encapsulation and Inheritance - Solutions For Class 10 ICSE Logix Kips Computer Applications With BlueJ Java - KnowledgeBoat

Chapter 13 of the ICSE Logix Kips Computer Applications with BlueJ discusses encapsulation and inheritance in Java, covering key concepts such as access specifiers, instance and static variables, and the types of inheritance. It includes multiple-choice and assignment questions to reinforce understanding of these topics. The chapter emphasizes the importance of encapsulation for data protection and the role of inheritance in code reusability.

Uploaded by

adithi.r785
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)
83 views10 pages

Chapter 13 - Encapsulation and Inheritance - Solutions For Class 10 ICSE Logix Kips Computer Applications With BlueJ Java - KnowledgeBoat

Chapter 13 of the ICSE Logix Kips Computer Applications with BlueJ discusses encapsulation and inheritance in Java, covering key concepts such as access specifiers, instance and static variables, and the types of inheritance. It includes multiple-choice and assignment questions to reinforce understanding of these topics. The chapter emphasizes the importance of encapsulation for data protection and the role of inheritance in code reusability.

Uploaded by

adithi.r785
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/ 10

5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications

ps Computer Applications with BlueJ Java | …

STUDY MATERIAL LOGIN JOIN NOW

Home / Class 10 - Logix Kips ICSE Computer Applications with BlueJ / Encapsulation and Inheritance

CONTENTS
Chapter 13
Search by lesson title
Encapsulation and Inheritance Multiple Choice Questions

Chapter 1 Assignment Questions


Class 10 - Logix Kips ICSE Computer Applications with BlueJ
Object Oriented Programming Concepts

Chapter 2
Introduction to Java

Chapter 3
Values and Data Types

Chapter 4
Operators in Java

Chapter 5
User-Defined Methods

Chapter 6
Input in Java

Chapter 7
Mathematical Library Methods

Chapter 8
Conditional Constructs in Java
Multiple Choice Questions
Chapter 9
Iterative Constructs in Java
Question 1
Chapter 10
Nested for loops
............... is the technique of binding both data and methods
Chapter 11
together to keep them safe from unauthorised access and misuse.
Constructors

Chapter 12 1. Abstraction
Library Classes

2. Inheritance
Chapter 13
Encapsulation and Inheritance
3. Encapsulation
Chapter 14
Arrays
4. Polymorphism

Chapter 15
Answer
String Handling

Encapsulation

Reason — Encapsulation is the technique of binding both data


and methods together to keep them safe from unauthorised access
and misuse.

Question 2

Which of the following is an access specifier?

1. public
2. protected
3. private
4. All of these

Answer

All of these

Reason — Public, private and protected are access specifiers.

Question 3

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 1/10
5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | …

A member variable declared with a public access specifier has


visibility in ............... .

1. Class
2. Package
3. Subclass
4. All of these

Answer

All of these

Reason — A member variable declared with a public access


specifier has visibility in the class, its sub classes and the package
as well.

Question 4

A member variable declared with a private access specifier has


visibility only in the ............... .

1. Class
2. Package
3. Subclass
4. All of these

Answer

Class

Reason — A member variable declared with a private access


specifier has visibility only in the class in which it is declared.

Question 5

A member variable declared with no access specifier has visibility


in ............... .

1. Class and package only


2. Class, package and subclass only
3. Class and subclass only
4. Class only

Answer

Class and package only

Reason — A member variable declared with no access specifier


has visibility in the same class and other classes of the same
package only.

Question 6

An instance variable ............... .

1. needs an instance to access it


2. does not need an instance to access it

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 2/10
5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | …

3. can be accessed using the class name


4. is declared with the static keyword

Answer

needs an instance to access it

Reason — An instance variable needs an instance (object) to


access it as each instance of the class has a separate copy of the
instance variable.

Question 7

A static variable ............... .

1. is preceded by static keyword in the declaration


2. is accessed via the class name
3. is also known as a class variable
4. All of the above

Answer

All of the above

Reason — A static variable is preceded by static keyword in the


declaration. It belongs to the class and hence, it is called a class
variable and is accessed via the class name.

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

Answer

Inheritance

Reason — Inheritance is the feature by means of which one class


acquires the properties of another class.

Question 9

The class that gets inherited is known as ............... .

1. Parent class
2. Base class
3. Super class
4. All of these

Answer

All of these

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 3/10
5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | …

Reason — The class that gets inherited is known as a parent


class, base class and super class as well.

Question 10

When many sub classes are inherited from a single base class, it
is known as ............... .

1. Hierarchical inheritance
2. Multiple inheritance
3. Single inheritance
4. Multilevel inheritance

Answer

Hierarchical inheritance

Reason — When many sub classes are inherited from a single


base class, it is known as Hierarchical inheritance.
Assignment Questions

Question 1

How does a class encapsulate state and behaviour?

Answer

A class encapsulates state and behavior by combining data and


functions into a single unit. The state of an object is represented by
its member variables and behaviour is represented by member
methods. By combining state and behavior within a single unit, the
class encapsulates the implementation details, allowing the outside
world to interact with the object through a well-defined interface.

Question 2

Name the access specifiers available in Java.

Answer

The access specifiers available in Java are:

1. public
2. private
3. protected

Question 3

Explain visibility in terms of the following access modifiers:

1. public
2. private
3. protected
4. no modifier specified

Answer

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 4/10
5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | …

1. public — The class members declared with the public access


specifier can be accessed from outside the class.
2. private — The class members declared with the private
access specifier can be accessed only within the ­class in
which they are declared.
3. protected — The class members declared with the protected
access specifier can be accessed within the same package
only. They are not accessible from outside the package,
except if the sub class is in the other package.
4. no modifier specified — When no access specifier is
mentioned, then by default that members of a class are public
within the package. They can be accessed within the same
package but not outside the package.

Question 4

Why is it a good idea to make all instance variables private?

Answer

It is a good idea to make all instance variables private because:

1. It hides the implementation details of the class from other


objects, which makes it easier to change the implementation
without affecting the rest of the system.
2. It provides encapsulation as the class defines a clear and well-
defined interface for interacting with its state.
3. It protects the state of the object by preventing external
objects from modifying the state in an unintended way.

Question 5

What do you mean by the scope of variables in Java?

Answer

The scope of a variable refers to that part of the program in which


the variable is accessible.

Question 6

Explain the scope of the following variables in Java:

1. Local variables
2. Parameter variables
3. Instance variables
4. Class variables

Answer

1. Local variables — The scope of local variables is limited to the


method or the block they are declared in. So, local variables
are accessible only to the method or block in which they are
declared. They are not accessible to the rest of the class.

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 5/10
5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | …

2. Parameter variables — The scope of parameter variables is


limited to the method where they are being used. Therefore,
parameter variables are visible only to the method in which
they are used. They are not accessible to the rest of the class.
3. Instance variables — The scope of an instance variable is
within the object that it belongs to, and it can be accessed
from any method of the class that it belongs to, within the
visibility restrictions defined by its access modifiers.
4. Class variables — A class variable can be accessed from any
instance of the class using the class name followed by the
variable name. It is shared among all instances of a class. It is
available as a single copy to all instances of the class.

Question 7

Explain the scope of variables in blocks and sub-blocks.

Answer

A variable declared in a block is visible (accessible) in the block


and in all the sub-blocks. However, it is not visible outside the
block.
Consider the given example:

void Add() {
int a = 10;
int b = 20;
if(a < b) { //Block 1
int sum = a + b;
System.out.println(sum);
}
else { //Block 2
int diff = a - b;
System.out.println(diff);
}
}

Here, the variables a and b will be accessible throughout the


block and its sub-blocks (Block 1 and Block 2) but the variable
sum will be accessible only in Block 1 and the variable diff will

be accessible only in Block 2.

Question 8

Is it legal to define local variables with the same identifier in nested


blocks?

Answer

No, it is illegal to define local variables with the same identifier in


nested blocks

The local variable declaration space of a block includes any nested


blocks. Thus, within a nested block it is not possible to declare a
local variable with the same name as a local variable in an
enclosing block.

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 6/10
5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | …
Question 9

Why do you need to use static variables in Java?

Answer

Static variables in Java are used when we want to create a


variable that is common to all objects of a class, rather than having
a separate instance of the variable for each object. This is useful in
situations where we need to keep track of information that applies
to a class as a whole, rather than to individual objects.

Some common use cases for static variables include:

1. Counter to keep track of the number of instances of a class


that have been created.
2. To store a constant value that is common to all objects of a
class.
3. To store configuration information that is common to all objects
of a class.

Question 10

What is the mechanism that allows one class to extend another


class?

Answer

Inheritance is the mechanism that allows one class to extend


another class.

Question 11

What do you call a class that is an extension of another class?

Answer

A class that is an extension of another class is known as a derived


class or child class or sub-class.

Question 12

What does the inheritance mechanism allow one class to acquire


from another?

Answer

The inheritance mechanism allows the derived class to inherit the


state and behaviour from the base class. The private data
members and member methods are not inherited by the sub class.

Question 13

How is inheritance transitive? Explain.

Answer

The transitive nature of inheritance means if class B is derived


from class A, class B will inherit all the properties of class A. Now

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 7/10
5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | …

all the sub classes of class B will also be able to inherit properties
of class A because of the transitive nature of inheritance.

Question 14

Explain various types of inheritance.

Answer

The various types of inheritance are as follows:

1. Single Inheritance — When a class is derived from only one


base class, it is known as single inheritance.
2. Multiple Inheritance — When a sub class is inherited from
multiple base classes, it is known as multiple inheritance.
3. Hierarchical Inheritance — When many sub classes are
inherited from a single base class, it is known as hierarchical
inheritance.
4. Hybrid Inheritance — When more than one type of
inheritance forms are used together, it is known as hybrid
inheritance.
5. Multilevel Inheritance — When a sub class is inherited from
a class that itself is being inherited from another class, it is
known as multilevel inheritance.

Question 15

Why do you need to use inheritance? Give two reasons.

Answer

We need to use inheritance for the following reasons:

1. Inheritance divides a program into useful and reusable set of


classes.
2. Changes made in the original class are reflected in all the
inherited classes.

Question 16

Declare a public class CoolClass.

1. Write the header for a public member method CoolMethodA.


2. Write the header for an integer member method CoolMethodB
that should be accessible to the classes in the package but not
to derived classes.
3. Write the header for an integer member method CoolMethodC
that should be accessible only to other methods of the class.
4. Write the header for a character member method
CoolMethodD that should be accessible to the classes in the
package and any derived classes.

Answer

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 8/10
5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | …

public class CoolClass


{
public void CoolMethodA() {

int CoolMethodB() {

private int CoolMethodC() {

protected char CoolMethodD() {

}
}

Prev Next
Library Classes Arrays

ICSE/ISC TEXTBOOK SOLUTIONS STUDYLIST COMPANY

Class - 6 Concise Biology Selina Solutions Java Pattern Programs About Us

Class - 6 Veena Bhargava Geography Solutions Java Series Programs Contact Us

Class - 6 Effective History & Civics Solutions Java Number Programs (ICSE Classes 9 / 10) Privacy Policy

Class - 6 APC Understanding Computers Solutions Java Number Programs (ISC Classes 11 / 12) Terms of Service

Class - 7 Concise Physics Selina Solutions Output Questions for Class 10 ICSE Computer Applications

Class - 7 Concise Chemistry Selina Solutions Algorithms & Flowcharts for ICSE Computers

Class - 7 Dalal Simplified Middle School Chemistry Solutions ICSE Class 8 Computers Differentiate Between the Following

Class - 7 Concise Biology Selina Solutions CBSE TEXTBOOK SOLUTIONS

Class - 7 Living Science Biology Ratna Sagar Solutions Class - 8 NCERT Science Solutions

Class - 7 Around the World Geography Solutions Class - 9 NCERT Science Solutions

Class - 7 Veena Bhargava Geography Solutions Class - 9 NCERT Geography Contemporary India 1 Solutions

Class - 7 Effective History & Civics Solutions Class - 9 Sumita Arora Computer Code 165 Solutions

Class - 7 APC Understanding Computers Solutions Class - 9 Kips Cyber Beans Computer Code 165 Solutions

Class - 8 Concise Physics Selina Solutions Class - 10 NCERT Mathematics Solutions

Class - 8 Concise Chemistry Selina Solutions Class - 10 NCERT Science Solutions

Class - 8 Dalal Simplified Middle School Chemistry Solutions Class - 10 NCERT Geography Contemporary India 2 Solutions

Class - 8 Concise Biology Selina Solutions Class - 10 NCERT History India & Contemporary World 2 Solutions

Class - 8 Living Science Biology Ratna Sagar Solutions Class - 10 Sumita Arora Computer Code 165 Solutions

Class - 8 Around the World Geography Solutions Class - 10 Kips Cyber Beans Computer Code 165 Solutions

Class - 8 Veena Bhargava Geography Solutions Class - 11 CBSE Sumita Arora Python Solutions

Class - 8 Effective History & Civics Solutions Class - 12 CBSE Sumita Arora Python Solutions

Class - 8 APC Understanding Computers Solutions Class - 12 CBSE Preeti Arora Python Solutions

Class - 8 Kips Logix Computers Solutions Class - 12 NCERT Computer Science Solutions

Class - 9 Concise Physics Selina Solutions

Class - 9 Concise Chemistry Selina Solutions

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 9/10
5/20/24, 1:34 PM Chapter 13: Encapsulation and Inheritance | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | …
Class - 9 Dalal Simplified ICSE Chemistry Solutions

Class - 9 Concise Biology Selina Solutions

Class - 9 Total Geography Morning Star Solutions

Class - 9 Veena Bhargava Geography Solutions

Class - 9 Total History & Civics Solutions

Class - 9 APC Understanding Computers Solutions

Class - 9 Kips Logix Computers Solutions

Class - 10 ML Aggarwal Mathematics Solutions

Class - 10 Concise Physics Selina Solutions

Class - 10 Concise Chemistry Selina Solutions

Class - 10 Dalal Simplified ICSE Chemistry Solutions

Class - 10 Concise Biology Selina Solutions

Class - 10 Total Geography Morning Star Solutions

Class - 10 Veena Bhargava Geography Solutions

Class - 10 Total History & Civics Solutions

Class - 10 APC Modern History & Civics Solutions

Class - 10 APC Understanding Computers Solutions

Class - 10 Sumita Arora ICSE Computers Solutions

Class - 10 Kips Logix Computers Solutions

Class - 11 APC Understanding Computers Solutions

Class - 12 APC Understanding Computers Solutions


ICSE/ISC SOLVED QUESTION PAPERS

ICSE Class 10 Computers Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Computer Applications

ICSE Class 10 Physics Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Physics

ICSE Class 10 Chemistry Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Chemistry

ICSE Class 10 Biology Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Biology

Class - 12 ISC Computer Science Solved Practical Papers

Class - 10 CBSE Computer Applications Solved Question Papers

Class - 10 CBSE Computer Applications Solved Sample Papers

Class - 10 CBSE Science Solved Question Papers

Class - 12 CBSE Computer Science Solved Question Papers

Copyright © KnowledgeBoat 2024

https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/qz0egZ/encapsulation-inheritance 10/10

You might also like