English

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 7 - Constructors [Latest edition]

Advertisements

Chapters

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 7 - Constructors - Shaalaa.com
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.


Review InsightEXERCISES
Review Insight [Pages 415 - 416]

Avichal solutions for Computer Applications [English] Class 10 ICSE 7 Constructors Review Insight [Pages 415 - 416]

Review Insight | Q 1. | Page 415

Distinguish between Parameterised constructor and Non-Parameterised constructor. 

Review Insight | Q 2. | Page 415

Explain the following term:

Constructor overloading

Review Insight | Q 3. | Page 415

What is a copy constructor? 

Review Insight | Q 4. | Page 415

"Member method and constructor can be defined private". Write whether the given statement is true or false, give reasons. 

  • True

  • False

Review Insight | Q 5. | Page 415

State two features of a constructor.

Review Insight | Q 6. | Page 415

Explain the following term:

Constructor overloading

Review Insight | Q 7. | Page 415

Which unit of the class gets called when the object of the class is created? 

Review Insight | Q 8. | Page 415

State the difference between constructor and method. 

Review Insight | Q 9. (i) | Page 415

What is meant by a constructor?

Review Insight | Q 9. (ii) | Page 415

when is a constructor invoked?

Review Insight | Q 10. | Page 415

Name the two types of constructors.

Review Insight | Q 11. | Page 416

What is a parameterised constructor? 

Review Insight | Q 12. (i) | Page 416

Create a class with one integer instance. Initialize the variable using: 

Default constructor.

Review Insight | Q 12. (ii) | Page 416

Create a class with one integer instance. Initialize the variable using:

Parameterised constructor. 

Case-Study based question

Review Insight | Q 13. | Page 416

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:

  1. GCD(......): A parameterised constructor to accept the values of nl and n2.
  2. void Compute(): To find GCD of the numbers n1 and n2.
  3. 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:

  1. What value will be filled in place of ?1?
    1. 1
    2. 0
    3. m
    4. t
  2. What logical expression will be filled in place of ?2?
    1. n1 %2 == 0
    2. n1/n2 == 0
    3. n1%n2 == 0
    4. n1%n2 != 0
  3. What variable will be filled in place of ?3?
    1. n1
    2. t
    3. n2
    4. gcd
  4. What variable will be filled in place of ?4?
    1. n2
    2. n1
    3. t
    4. None
EXERCISES [Pages 417 - 421]

Avichal solutions for Computer Applications [English] Class 10 ICSE 7 Constructors EXERCISES [Pages 417 - 421]

Multiple Choice Questions:

EXERCISES | Q I. 1. | Page 417

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

EXERCISES | Q I. 2. | Page 417

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.

EXERCISES | Q I. 3. | Page 417

A constructor is always: 

  • Private

  • Protected

  • Secure

  • Public

EXERCISES | Q I. 4. | Page 417

Which constructor initialises data members with default values? 

  • Parameterized constructor

  • Non-parameterized constructor

  • Copy constructor

  • Default constructor 

EXERCISES | Q I. 5. | Page 417

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:

EXERCISES | Q II. 1. | Page 417

A member function having the same name as that of the class name is called ______. 

EXERCISES | Q II. 2. | Page 418

A constructor has ______ return type. 

EXERCISES | Q II. 3. | Page 418

A constructor is used when an ______ is created. 

EXERCISES | Q II. 4. | Page 418

A constructor without any argument is known as ______.

EXERCISES | Q II. 5. | Page 418

A ______ constructor creates objects by passing value to it. 

EXERCISES | Q II. 6. | Page 418

The ______ refers to the current object. 

EXERCISES | Q II. 7. | Page 418

The argument of a copy constructor is always passed by ______.

EXERCISES | Q II. 8. | Page 418

The constructor generated by the compiler is known as ______.

Write True or False for the following statements:

EXERCISES | Q III. 1. | Page 418

The compiler supplies a special constructor in a class that does not have any constructor.

  • True

  • False

EXERCISES | Q III. 2. | Page 418

A constructor is not defined with any return type.

  • True

  • False

EXERCISES | Q III. 3. | Page 418

Every class must have all types of constructors.

  • True

  • False

EXERCISES | Q III. 4. | Page 418

A constructor is a member methods of a class. 

  • True 

  • False

EXERCISES | Q III. 5. | Page 418

A constructor is used to initialize the data members of a class.

  • True

  • False

EXERCISES | Q III. 6. | Page 418

A constructor may have different names than the class name.

  • True

  • False

EXERCISES | Q III. 7. | Page 418

A constructor is likely to be defined after the class declaration. 

  • True

  • False

EXERCISES | Q III. 8. | Page 418

Copy constructor copies functions from one object to another. 

  • True

  • False

Case-Study based question:

EXERCISES | Q IV. | Page 418

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:

  1. Which name resembles with the constructor name?
  2. What type of constructor is used with parameters?
  3. What type of constructor initialises the instance variables with default value?
  4. Which constructor is used to duplicate the initial values from one constructor to other? 

Answer the following:

EXERCISES | Q V. 1. | Page 418

What is meant by a constructor?

EXERCISES | Q V. 2. | Page 418

Name the different types of constructors used while defining a class. 

EXERCISES | Q V. 3. | Page 418

Why do we need a constructor as a class member?

EXERCISES | Q V. 4. (a) | Page 418

Explain the following term:

Constructor with default argument

EXERCISES | Q V. 4. (b) | Page 418

Explain the following term:

Parameterised constructor

EXERCISES | Q V. 4. (c) | Page 418

What is a copy constructor? 

EXERCISES | Q V. 4. (d) | Page 418

Explain the following term:

Constructor overloading

EXERCISES | Q V. 5. | Page 418

Why is an object not passed to a constructor by value? Explain. 

EXERCISES | Q V. 6. | Page 418

State the difference between constructor and method. 

EXERCISES | Q V. 7. | Page 418

Explain two features of a constructor. 

EXERCISES | Q V. 8. | Page 418

Distinguish between Parameterised constructor and Non-Parameterised constructor. 

EXERCISES | Q V. 9. | Page 418

Name two ways of creating objects in a constructor.

EXERCISES | Q V. 10. | Page 419

Differentiate between the following statements:

abc p = new abc();
abc p = new abc(5,7,9); 

EXERCISES | Q V. 11. | Page 419

Fill in the blanks to design a class: 

class ..................
{
int l, b
    Area( int ........, int .........)
    l = ..............;
    b = ..............;
}

Unsolved Programs in Java based on Constructors:

EXERCISES | Q VI. 1. | Page 419

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.

EXERCISES | Q VI. 2. | Page 419

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:

  1. a parameterised constructor to initialize the data members.
  2. to accept the details (name of the customer and the price).
  3. to compute the discount.
  4. 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.

EXERCISES | Q VI. 3. | Page 419

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

EXERCISES | Q VI. 4. | Page 419

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:

  1. a parameterised constructor to initialize the data member
  2. to accept the word
  3. to arrange all the alphabets of word in ascending order of their ASCII values without using the sorting technique
  4. to display the arranged alphabets.

Write a main method to create an object of the class and call the above member methods. 

EXERCISES | Q VI. 5. | Page 420

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 

EXERCISES | Q VI. 6. | Page 420

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.

EXERCISES | Q VI. 7. | Page 420

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)`

EXERCISES | Q VI. 8. | Page 420

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:

  1. FruitJuice(): constructor to initialize integer data members to 0 and string data members to " ".
  2. void input(): to input and store the product code, flavour, pack type, pack size and product price.
  3. void discount(): to reduce the product price by 10.
  4. void display(): to display the product code, flavour, pack type, pack size and product price.
EXERCISES | Q VI. 9. | Page 421

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. 

EXERCISES | Q VI. 10. | Page 421

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.

EXERCISES | Q VI. 11. | Page 421

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.

EXERCISES | Q VI. 12. | Page 421

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:

  1. BookFair(): constructor to initialize data members
  2. void input(): to input and store the name and price of the book
  3. 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

Review InsightEXERCISES
Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 7 - Constructors - Shaalaa.com

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.

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×