Advertisements
Online Mock Tests
Chapters
1.2: Elementary Concept of Objects and Classes
1.3: Values and Data Types
1.4: Operators in Java
1.5: Introduction to Java
1.5: Input in Java
1.6: Mathematical Library Methods
1.7: Conditional Statements in Java
1.8: Iterative Constructs in Java
1.9: Nested Loop
2: Library Classes
3: Arrays (Single Dimensional and Double Dimensional)
4: String Handling
5: User - Defined Methods
6: Class as the Basis of all Computation (Objects and Classes)
7: Constructors
▶ 8: Encapsulation and Inheritance
![Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 8 - Encapsulation and Inheritance Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 8 - Encapsulation and Inheritance - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
Advertisements
Solutions for Chapter 8: Encapsulation and Inheritance
Below listed, you can find solutions for Chapter 8 of CISCE Avichal for Computer Applications [English] Class 10 ICSE.
Avichal solutions for Computer Applications [English] Class 10 ICSE 8 Encapsulation and Inheritance Review Insight [Page 443]
What is meant by encapsulation?
In what way is a class Encapsulated?
What is meant by protected visibility?
In what way does Inheritance support reusability?
What is the difference between base class and derived class?
Case-Study based question:
In object oriented programming, the data and functions are wrapped together so that the data members should be accessed within the scope of a class. To adopt this principle, the data are declared with an access specifier. A class can also acquire some features from another class. This is called inheritance. Inheritance can be of different types. One type of inheritance allows acquiring the features of a base class into multiple targets. However, sharing multiple bases to a single target is not allowed in Java.
Based on the above discussion, answer the following questions:
- What is the term used for wrapping data and functions as a unit?
- Inheritance
- Polymorphism
- Object
- Encapsulation
- Name the access specifier that allows accessing data members within the scope of a class?
- public
- private
- protected
- secure
- Which type of inheritance allows accessing a base into multiple targets?
- Hierarchical
- Single
- Multilevel
- Hybrid
- Which type of inheritance is not allowed in Java?
- Multilevel
- Multiple
- Hierarchical
- Nested
Avichal solutions for Computer Applications [English] Class 10 ICSE 8 Encapsulation and Inheritance EXERCISES [Pages 444 - 448]
Multiple Choice Questions:
Which type of data is not accessed in a derived class?
Public
Private
Protected
None
A private member method is only accessed:
In the scope of the same class in which it is defined.
Anywhere outside the class in which it is defined.
In the derived class.
None of the above.
A ______ variable is a common field for all the objects of a class.
Local variable
Global variable
Class variable
Instance variable
Which of the following data is a separate field for all the objects of a class?
Local variable
Class variable
Instance variable
Primitive variable
Which of the following is a combination of more than one inheritance system?
Hybrid inheritance
Multiple inheritance
Single inheritance
Hierarchical inheritance
What is another name of multilevel inheritance?
Single inheritance
Nested inheritance
Multiple inheritance
Derived inheritance
Fill in the blanks with appropriate words:
Derived class inherits from ______ class.
Because of ______ the reusability of an object code comes into existence.
Super class is the term used for ______ class.
A ______ class derives a base class.
A ______ class is also known as Target.
The process of sharing characteristics with classes is called ______.
A derived class inherits from a single base is known as ______ inheritance.
Java doesn't allow ______ inheritance.
A base class derived by a target, in turn used as base class for another target is called ______.
State True or False for the following statements:
Inheritance supports reusability.
True
False
During inheritance, the public and protected members remain in the same form in the derived class.
True
False
Inheritance is a transitive property.
True
False
Base class is used to inherit the property of a derived class.
True
False
During inheritance if no visibility mode is declared then the system automatically assumes it to be private.
True
False
Visibility modes decide the access provided to the members from the target.
True
False
Constructors of base and derived classes are automatically invoked while creating the objects of derived class.
True
False
A target does not have access to the private members of base class.
True
False
A single target inheriting many bases is known as multilevel inheritance.
True
False
Case-Study based question:
A number is said to be Armstrong if the sum of cube of its digits is equal to the same number.
For example, 153 = 13 + 53 + 33
Hence, 153 is an Armstrong number.
A program using a class is designed below to check and display whether a number 'num' is an Armstrong number or not. There are some places in the program left blank marked with ?1?, ?2?, ?3? and ?4? to be filled with suitable condition/expression.
class Armstrong
{
private int num;
Armstrong(int n)
{
num = n;
}
boolean check()
(
int nm= num;
while(....... ?1? ........)
{
digit = nm % 10;
sum = sum + ......... ?2? .......;
nm = ........ ?3? .........;
}
if (sum == num)
return(true);
else
return(false)
}
void display()
{
boolean ch = check();
if (ch == ....... ?4? .......)
System.out.println("Number is Armstrong");
Else
System.out.println("Number is not Armstrong");
}
Based on the above discussion, answer the following questions:
- What will be filled in place of ?1?
- What will be filled in place of ?2?
- What will be filled in place of ?3?
- What will be filled in place of ?4?
Answer the following:
What is meant by encapsulation?
In what way does a class enforce data hiding?
What are the types of visibility modes used in Java?
What will happen if data members are declared private?
What is inheritance?
What is meant by a base class?
Differentiate between super class and target.
What is the significance of using protected declaration during inheritance? Show with the help of an example.
Main class by default inherits another class. Explain the given statement.
With the help of an example explain how you can access a private member of a base class.
Why is the main method in Java so special?
What is meant by scope of variables? Show its application with the help of an example.
In what way does the access specifier of the base class have access control over the derived class? Show with the help of an example.
Suppose, 'Happening' and 'Accident' are two classes. What will happen when Happening class derives from Accident class by using private visibility?
Give reason:
In what circumstances is a class derived publicly?
Give reason:
In what circumstances is a class derived privately?
Describe the method of accessing the data member and member function of a class in the following case:
in the member function of the same class.
Describe the method of accessing the data member and member function of a class in the following case:
in the member function of another class.
Describe the method of accessing the data member and member function of a class in the following case:
in the member function of base class.
Can a private member be accessed by a member of the same class?
Can a private member be accessed by a member of other class?
Can a private member be accessed by a function which is not a member function?
Show with the help of an example, how the following base classes can be derived in class bill to fulfill the given requirement:
class Elect
{
String n;
float units;
public void setvalue()
{
n = "SOURABH"
units = 6879;
}
}
class Bill uses data members charge and a member function to calculate the bill at the rate of ₹ 3.25 per unit and displays the charge. Class Elect is inherited by class Bill by using private visibility.
Unsolved Java Programs on Encapsulation and Inheritance:
Write a program by using a class with the following specifications:
Class name: Prime
Data Members: private int n
Member Methods:
void input(): to input a number
void checkprirne(): to check and display whether the number is prime or not.
Use a main function to create an object and call member methods of the class.
Write a program by using a class with the following specifications:
Class name: Factorial
Data Members: private int n
Member Methods:
void input(): to input a number
void fact(): to find and print the factorial of the number.
Use a main function to create an object and call member methods of the class.
Write a program by using a class with the following specifications:
Class name: Salary
Data Members: private int basic
Member Methods:
void input(): to input basic pay
void display(): to find and print the following-
da = 30% of basic,
hra = 10% of basic,
gross = basic + da + hra
Use a main function to create an object and call member methods of the class.
Write a class program with the following specifications:
Class name: Matrix
Data Members : int array m[][] with 3 rows and 3 columns
Member Methods:
void getdata(): to accept the numbers in the array
void rowsum(): to find and print the sum of the numbers of each row
void colsum(): to find and print the sum of numbers of each column
Use a main function to create an object and call member methods of the class.
Write a program to use a class Account with the following specifications:
Class name: Account
Data Members: int acno, float balance
Member Methods:
Account (int a, int b): to initialize acno = a, balance = b
void withdraw(int w): to maintain the balance with withdrawal (balance − w)
void deposit(int d): to maintain the balance with the deposit (balance + d)
Use another class Calculate which inherits from class Account with the following specifications:
Class name: Calculate
Data Members: int r,t ; float si,amt;
Member Methods:
void accept(int x, int y): to initialize r=x,t=y,amt=0
void compute(): to find simple interest and amount
si = (balance*r*t)/100;
a=a+si;
void display(): to print account number, balance, interest and amount.
main() function need not to be used.
Write a program by using class with the following specifications:
Class name: Sale
Data Members/Instance variables
String title, author, publication
double price
Member Methods:
void input(): to accept title, author name and publication name and price of a book
void display(): to display title, author name and publication name and price of a book
Now, create another class 'Purchase' that inherits class 'Sale' having the following specification:
Class name: Purchase
Data Members/Instance variables:
int noc
int amount;
Member Methods:
void accept(): to enter the number of copies purchased
void calculate(): to find the amount by multiplying number of copies ordered and price (i.e., noc * price)
void show(): to display the elements describes in base class along with the number of copies purchased and amount to be paid to the shopkeeper.
Write a program to define class with the following specifications:
Class name : Number
Data members/instance variables:
int n: to hold an integer number
Member Methods:
void input(): to accept an integer number in n
void display(): to display the integer number input in n.
Now, inherit class Number to another class Check that is defined with the following specifications:
Class name : Check
Data Members/Instance variables:
int fact
int revnum
Member Methods:
void find(): to find and print factorial of the number used in base class
void palindrome(): to check and print whether the number used in base class is a palindrome number or not
[A number is said to be palindrome if it appears the same after reversing its digits. For example, 414, 333, 515, etc.]
Solutions for 8: Encapsulation and Inheritance
![Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 8 - Encapsulation and Inheritance Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 8 - Encapsulation and Inheritance - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 8 - Encapsulation and Inheritance
Shaalaa.com has the CISCE Mathematics Computer Applications [English] Class 10 ICSE CISCE solutions in a manner that help students grasp basic concepts better and faster. The detailed, step-by-step solutions will help you understand the concepts better and clarify any confusion. Avichal solutions for Mathematics Computer Applications [English] Class 10 ICSE CISCE 8 (Encapsulation and Inheritance) include all questions with answers and detailed explanations. This will clear students' doubts about questions and improve their application skills while preparing for board exams.
Further, we at Shaalaa.com provide such solutions so students can prepare for written exams. Avichal textbook solutions can be a core help for self-study and provide excellent self-help guidance for students.
Concepts covered in Computer Applications [English] Class 10 ICSE chapter 8 Encapsulation and Inheritance are Introduction to Encapsulation, Scope of Variables, Inheritance, Types of Inheritance.
Using Avichal Computer Applications [English] Class 10 ICSE solutions Encapsulation and Inheritance exercise by students is an easy way to prepare for the exams, as they involve solutions arranged chapter-wise and also page-wise. The questions involved in Avichal Solutions are essential questions that can be asked in the final exam. Maximum CISCE Computer Applications [English] Class 10 ICSE students prefer Avichal Textbook Solutions to score more in exams.
Get the free view of Chapter 8, Encapsulation and Inheritance Computer Applications [English] Class 10 ICSE additional questions for Mathematics Computer Applications [English] Class 10 ICSE CISCE, and you can use Shaalaa.com to keep it handy for your exam preparation.