Advertisements
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 7 - Constructors Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 7 - Constructors - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
Advertisements
Solutions for Chapter 7: Constructors
Below listed, you can find solutions for Chapter 7 of CISCE Avichal for Computer Applications [English] Class 10 ICSE.
Avichal solutions for Computer Applications [English] Class 10 ICSE 7 Constructors Review Insight [Pages 415 - 416]
Distinguish between Parameterised constructor and Non-Parameterised constructor.
Explain the following term:
Constructor overloading
What is a copy constructor?
"Member method and constructor can be defined private". Write whether the given statement is true or false, give reasons.
True
False
State two features of a constructor.
Explain the following term:
Constructor overloading
Which unit of the class gets called when the object of the class is created?
State the difference between constructor and method.
What is meant by a constructor?
when is a constructor invoked?
Name the two types of constructors.
What is a parameterised constructor?
Create a class with one integer instance. Initialize the variable using:
Default constructor.
Create a class with one integer instance. Initialize the variable using:
Parameterised constructor.
Case-Study based question
The following program is designed using a class to find GCD of two numbers with the following specifications.
class name : GCD
Data members : n1, n2
Member Methods:
- GCD(......): A parameterised constructor to accept the values of nl and n2.
- void Compute(): To find GCD of the numbers n1 and n2.
- void display(): To display GCD of the numbers.
There are some places left blank marked with ?1?, ?2?, ?3? and ?4? to be filled with the value/expression.
import java.util.*;
class GCD
{
int n1, n2, t = 0;
GCD( ..... ?1?...., n)
{
n1 = m;
n2 = n;
void Compute()
{
while(.....?2?.....)
{
t = n1 % n2;
n1 = n2;
n2 = ?3?;
}
}
void Display()
{
System.out.println("GCD of two numbers = " + ....?4?.....);
}
}
Based on the above discussion, answer the following questions:
- What value will be filled in place of ?1?
- 1
- 0
- m
- t
- What logical expression will be filled in place of ?2?
- n1 %2 == 0
- n1/n2 == 0
- n1%n2 == 0
- n1%n2 != 0
- What variable will be filled in place of ?3?
- n1
- t
- n2
- gcd
- What variable will be filled in place of ?4?
- n2
- n1
- t
- None
Avichal solutions for Computer Applications [English] Class 10 ICSE 7 Constructors EXERCISES [Pages 417 - 421]
Multiple Choice Questions:
For which purpose a constructor is used?
To initialise the instance variables
To provide the instance variables
To organise the instance variables
To simplify the instance variables
Which of the following statements is false?
A constructor has same name as class name.
A constructor returns initial value.
A constructor is called while creating an object.
A constructor is not used for arithmetical and logical operations.
A constructor is always:
Private
Protected
Secure
Public
Which constructor initialises data members with default values?
Parameterized constructor
Non-parameterized constructor
Copy constructor
Default constructor
What is not true for a constructor?
It is used only to initialize the data members.
It returns a unique value.
It may not use parameter.
None of the above.
Fill in the blanks with appropriate words:
A member function having the same name as that of the class name is called ______.
A constructor has ______ return type.
A constructor is used when an ______ is created.
A constructor without any argument is known as ______.
A ______ constructor creates objects by passing value to it.
The ______ refers to the current object.
The argument of a copy constructor is always passed by ______.
The constructor generated by the compiler is known as ______.
Write True or False for the following statements:
The compiler supplies a special constructor in a class that does not have any constructor.
True
False
A constructor is not defined with any return type.
True
False
Every class must have all types of constructors.
True
False
A constructor is a member methods of a class.
True
False
A constructor is used to initialize the data members of a class.
True
False
A constructor may have different names than the class name.
True
False
A constructor is likely to be defined after the class declaration.
True
False
Copy constructor copies functions from one object to another.
True
False
Case-Study based question:
While creating a class, a specific method called constructor is defined to initialise the instance variables. Such method may or may not use parameters. In a case where the constructor is not defined in the class, the system creates on its own to put the default initial value to the instance variables. The initial values can also be duplicated from one instance to another.
Based on the above discussion, answer the following questions:
- Which name resembles with the constructor name?
- What type of constructor is used with parameters?
- What type of constructor initialises the instance variables with default value?
- Which constructor is used to duplicate the initial values from one constructor to other?
Answer the following:
What is meant by a constructor?
Name the different types of constructors used while defining a class.
Why do we need a constructor as a class member?
Explain the following term:
Constructor with default argument
Explain the following term:
Parameterised constructor
What is a copy constructor?
Explain the following term:
Constructor overloading
Why is an object not passed to a constructor by value? Explain.
State the difference between constructor and method.
Explain two features of a constructor.
Distinguish between Parameterised constructor and Non-Parameterised constructor.
Name two ways of creating objects in a constructor.
Differentiate between the following statements:
abc p = new abc();
abc p = new abc(5,7,9);
Fill in the blanks to design a class:
class ..................
{
int l, b
Area( int ........, int .........)
l = ..............;
b = ..............;
}
Unsolved Programs in Java based on Constructors:
Write a program by using a class with the following specifications:
Class name : Hcflcm
Data members/Instance variables : int a,b
Member Methods:
Hcflcm(int x, int y): constructor to initialize a=x and b=y.
void calculate(): to find and print hcf and km of both the numbers.
An electronics shop has announced a special discount on the purchase of laptops as given below:
Category | Discount on Laptop |
Up to ₹ 25,000 | 5.0% |
₹ 25,001 − ₹ 50,000 | 7.5% |
₹ 50,001 − ₹ 1,00,000 | 10.0% |
More than ₹ 1,00,000 | 15.0% |
Define a class Laptop described as follows:
Data members/Instance variables: name, price, dis, amt;
Member methods:
- a parameterised constructor to initialize the data members.
- to accept the details (name of the customer and the price).
- to compute the discount.
- to display the name, discount and amount to be paid after discount.
Write a main method to create an object of the class and call the member methods.
Write a program by using a class with the following specifications:
Class name: Calculate
Instance variables: int num, f, rev
Member Methods:
Calculate (int n): to initialize num with n, f and rev with 0 (zero)
int prime(): to return 1, if number is prime
int reverse(): to return reverse of the number
void display(): to check and display whether the number is a prime palindrome or not
Define a class Arrange described as below:
Data members/Instance variables: String str (a word), i, p (to store the length of the word), char ch;
Member Methods:
- a parameterised constructor to initialize the data member
- to accept the word
- to arrange all the alphabets of word in ascending order of their ASCII values without using the sorting technique
- to display the arranged alphabets.
Write a main method to create an object of the class and call the above member methods.
Write a program by using a class in Java with the following specifications:
Class name: Stringop
Data members: String str
Member Methods:
Stringop(): to initialize str with NULL.
Stringop(): to initialize str with NULL.
void encode(): to replace and print each character of the string with the second next character in the ASCII table.
Example: A with C, B with D and so on ...
void print(): to display each word of the String in a separate line
The population of a country in a particular year can be calculated by:
p*(l+r/100) at the end of year 2000, where p is the initial population and r is the growth rate.
Write a program by using a class to find the population of the country at the end of each year from 2001 to 2007. The Class has the following specifications:
Class name: Population
Data Members: float p,r
Member Methods:
Population( int a,int b): Constructor to initialize p and r with a and b respectively.
void print(): to calculate and display the population of each year from 2001 to 2007.
Write a program in Java to find the roots of a quadratic equation ax2+bx+c=0 with the following specifications:
Class name: Quad
Data Members: float a,b,c,d (a,b,c are the co-efficients & d is the discriminant), r1 and r2 are the roots of the equation.
Member Methods:
quad(int x,int y,int z): to initialize a=x,b=y,c=z,d=O
void calculate() : Find d=b2−4ac
If d<0 then display "Roots not possible" otherwise find and display:
r1= `(-"b" + sqrtd)/(2a)` and r2 = `(-b - sqrtd)/(2a)`
Define a class named FruitJuice with the following description:
Instance variables/Data members:
int product_code: stores the product code number.
String flavour: stores the flavour of the juice (e.g., orange, apple, etc.)
String pack_type: stores the type of packaging (e.g., tera-pack, PET bottle, etc.)
int pack_size: stores package size (e.g., 200 mL, 400 mL, etc.)
int product_price: stores the price of the product
Member Methods:
- FruitJuice(): constructor to initialize integer data members to 0 and string data members to " ".
- void input(): to input and store the product code, flavour, pack type, pack size and product price.
- void discount(): to reduce the product price by 10.
- void display(): to display the product code, flavour, pack type, pack size and product price.
The basic salary of employees is undergoing a revision. Define a class called Grade_ Revision with the following specifications:
Instance variables/Data members:
String name: to store name of the employee
int bas: to store basic salary
int expn: to consider the length of service as an experience
double inc: to store increment
double nbas: to store new basic salary (basic + increment)
Member Methods:
Grade_Revision(): constructor to initialize all data members
void accept(): to input name, basic and experience
void increment(): to calculate increment with the following specifications:
Experience | Increment |
Up to 3 years | ₹ 1,000 + 10% of basic |
3 years or more and up to 5 years | ₹ 3,000 + 12% of basic |
5 years or more and up to 10 years | ₹ 5,000 + 15% of basic |
10 years or more | ₹ 8,000 + 20% of basic |
void display(): to display all the details of an employee.
Write the main method to create an object of the class and call all the member methods.
Define a class called Student to check whether a student is eligible for taking admission in class XI with the following specifications:
Instance variables/Data members:
String name: to store name
int mm: to store marks secured in Maths
int scm: to store marks secured in Science
int comp: to store marks secured in Computer
Member Methods:
Student(): parameterised constructor to initialize the data members by accepting the details of a student
check(): to check the eligibility for course with the following conditions:
Marks | Eligibility |
90% or more in all the subjects | Science with Computer |
Average marks 90% or more | Bio-Science |
Average marks 80% or more and less than 90% | Science with Hindi |
display(): to display the eligibility by using check() function in nested form.
Write the main method to create an object of the class and call all the member methods.
Define a class Bill that calculates the telephone bill of a consumer with the following description:
Instance variables/Data members:
int bno: bill number
String name: name of consumer
int call: no. of calls consumed in a month
double amt: bill amount to be paid by the person
Member methods
Bill(): constructor to initialize data members with default initial value
Bill(...): parameterised constructor to accept bill no, name and no. of calls consumed.
Calculate(): to calculate the monthly telephone bill for a consumer as per the following condition
Units consumed | Rate |
First 100 calls | ₹ 0.60/call |
Next 100 calls | ₹ 0.80/call |
Next 100 calls | ₹ 1.20/call |
Above 300 calls | ₹ 1.50/call |
Fixed monthly rental applicable to all consumers: ₹ 125
Display(): to display the details
Create an object in the main() method and invoke the above functions to perform the desired task.
Define a class called BookFair with the following description:
Instance variables/Data members:
String Bname: stores the name of the book
double price: stores the price of the book
Member Methods:
- BookFair(): constructor to initialize data members
- void input(): to input and store the name and price of the book
- void calculate(): to calculate the price after discount. Discount is calculated based on the following criteria:
Price | Discount |
Less than or equal to ₹ 1000 | 2% of price |
More than ₹ 1000 and less than or equal to ₹ 3000 | 10% of price |
More than ₹ 3000 | 15% of price |
iv. void display(): to display the name and price of the book after discount
Write a main method to create an object of the class and call the above member methods.
Solutions for 7: Constructors
![Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 7 - Constructors Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 7 - Constructors - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 7 - Constructors
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 7 (Constructors) 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 7 Constructors are Concept of Constructor, Need of using a Constructor, Features of a Constructor, Types of Constructor, Constructor Overloading, Invoking a Constructor.
Using Avichal Computer Applications [English] Class 10 ICSE solutions Constructors 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 7, Constructors 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.