ICSE Class X Computer Applications ( Java ) Solved Model Question Papers

ICSE Class X Computer Applications ( Java ) Solved Question Papers

ICSE Class X solved model paper for 2018

Model Paper Solved
Section A (40 Marks)
Attempt all question

Question 1.
a.       Define Encapsulation.
Ans: The wrapping of data and function together into a single unit is called Encapsulation.
b.      Name any two OOP’s principles
Ans: Inheritance and Polymorphism
c.       Define Object with an example.
Ans:  Object: An instance of a class called Object. The table is an instance of class Furniture.
Class: Blue print of an object is called Class. Example, mango, apple, and orange are members of the class fruit.
d.      What is wrapper class? Give example.
e.      A wrapper class is a class which wraps a primitive data type. Example Double, Float, Integer


Question 2.
a.       What is a class variable?
Ans: Instance variables having the keyword static before it is a class variable. For every object, there is just one copy of the variable made.
b.      What is the significance of import java.io.* in your program?
Ans: The line imports all the classes of the java.io package into the current program.
c.       State the two kinds of data types.
Ans: The two kinds of data types in Java are primitive and reference data types.
d.      Define impure function.
Ans: Impure Function: A function that brings about a change in the argument that it receives. Its arguments will always be reference types. It may or may not return value. In other words, an impure function brings about a change in the state of the function. This change in state is called the side effect of calling an impure function.
Example:
Static void count(Number num) 
{
        num.counter=num.counter+1;
}
e.      What are comments? Name the different types.
Ans: Comments are statements which enhance the readability and understanding of the program. They are not part of the program.
The different types are: single line (//….), multiple line (/* … */) and documenting comment (/**….*/).



Question 3.
a.       What is meant by the private visibility of a method?
Ans:  The visibility of private method restricted to the class itself. It is not visible to anywhere outside the class.
b.      What is a variable?
Ans: A variable is a named memory location whose value can change. Example int a,b;
c.       What is the use of return keyword?
Ans: A return keyword is used to return any value from a function. It denotes the end of a function.
d.      What is call by value?
Ans: In call by value arguments are passed by the value, which means that a copy of the arguments is passed to the method can make changes to the value of this copy but can not change the values of the original variables in the calling method.
e.      What is meant by an infinite loop? Give an example.
Ans: An infinite loop is a loop whose test condition is always true. This type of loop never ends by itself. For example:
for(i=1;i>0;i++)
{
        System.out.println(“Hello”);
}
f.        State any two objectives of using Arrays.
Ans:  1. Use hold elements in contiguous memory location. 2. Arrays are used to group storage locations.





Section B (60 Marks)
Attempt any four questions from this Section

Question  4.
Design a program in Java to calculate the tax for the people living in Mango city. Specify a class taxpayer whose class description is given below:                                                                                                                                                                                    [15]
Class name:                                         TaxCalculator
Data members:                                    int PAN
                                                                String name
                                                                double  taxableIncome
                                                                double  tax
Member methods:                               inputData()
                                                            displayData()
                                                            computeData()
The tax is calculated according to the following rules:
Total Annual Taxable Income
Rate of Taxation
Up to 60000
0%
Above 60000 but up to 150000
5%
Above 150000 but up to 500000
10%
Above 500000
15%

Solution
import java.io.*;
/**
 * class TaxCalculator here.
 *
*
 */
public class TaxCalculator
{
       int pan;
       String name;
       double taxableIncome;
       double tax;
       void input()throws IOException
       {
              InputStreamReader in=new InputStreamReader(System.in);
              BufferedReader br=new BufferedReader(in);
              System.out.println("Enter name and taxable income:");
              name=br.readLine();
               taxableIncome=Double.parseDouble(br.readLine());
       }
      void computeData()
      {
               if(taxableIncome<=60000)
                   tax=0;
               else if(taxableIncome>60000 && taxableIncome<=150000)
                  tax=taxableIncome*0.05;
               else if(taxableIncome>150000 && taxableIncome<=500000)
                  tax=taxableIncome*0.1;
             else
                  tax=taxableIncome*0.2;
      }
      void displayData()
      {
        System.out.println("Display Data”);
        System.out.println("Name =" + name);
        System.out.println("Taxable Income =" + taxableIncome);
        System.out.println("Tax Paid =" + tax);
    }
    
    public static void main(String args[])throws IOException
    {
        TaxCalculator ob=new TaxCalculator();
        ob.input();
        ob.computeData();
        ob.displayData();
    }
}
Output:
Enter name and taxable income:
Rehan
120000
Display Data
Name=Rehan
Taxable Income=120000.0
Tax Paid=6000.0

Question 5
Write a menu driven program to convert Fahrenheit to Celsius and Celsius to Fahrenheit.

Solution:
import java.io.*;
import java.io.*;
/**
 * Class FahrenToCelsius
*
 */
public class FahrenToCelsius
{
    public static void main(String args[])throws IOException
    {
        int ch,c,f;
        InputStreamReader ab=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(ab);
        // Menu List
        System.out.println("Enter 1. Farenheit to Celsius:");
        System.out.println("Enter 2. Celsius To Farenheit:");
        System.out.print("Enter Choice :");
        ch=Integer.parseInt(br.readLine());
        // switch statement
        switch(ch)
        {
            case 1:
                System.out.print("Enter Temperature in Farenheit :");
                f=Integer.parseInt(br.readLine());
                c=((f-32)*5)/9;
                System.out.println("Temperature in Celsius :"+c);
                break;
            case 2:
                System.out.print("Enter Temperature in Celsius :");
                c=Integer.parseInt(br.readLine());
                f=(9*c/5)+32;
                System.out.println("Temperature in Farenheit :"+f);
                break;
       }
    }
}

Output :
Enter 1. Farenheit to Celsius:
Enter 2. Celsius To Farenheit:
Enter Choice :1
Enter Temperature in Farenheit :100
Temperature in Celsius :37
Enter 1. Farenheit to Celsius:
Enter 2. Celsius To Farenheit:
Enter Choice :2
Enter Temperature in Celsius :100
Temperature in Farenheit :212

Question 6.
 Write a class Automorphic  to check whether a number is Automorphic or not using function with the help of a method
Int digit(int n)
Solution
import java.io.*;
/**
 * class Automorphic
*
 */
public class Automorphic
{
    int digits(int n)
    {
        int c,p,k;c=0;k=0;
        while(n!=0)
        {
            k=n/10;
            c=c+1;
            n=k;
        }
        return(c);
    }

    public static void main(String args[])throws IOException
    {
        InputStreamReader read =new InputStreamReader(System.in);
        BufferedReader in =new BufferedReader(read);
        int m,n,p,b;
        double r;
        r = 0;
        Automorphic ob= new Automorphic();
        System.out.println("Enter your no.");
        n=Integer.parseInt(in.readLine());
        m= n;
        p= m * m;
        b=ob.digits(n);
        r=p % (Math.pow(10,b));
        if(m==r)
            System.out.println(m + " is an Automorphic no.");
        else
            System.out.println(m + " is not an Automorphic no.");
    }
}

Output;
Enter your no.
625
625 is an Automorphic no.
Enter your no.
525
525 is not an Automorphic no.
Question 7
. A cloth showroom has announced the following festival discounts on the purchase of items based on
    the total cost of the items purchased:
                                    Total cost                                   Discount (in Percentage)
                                    Less than Rs. 2000                                  5%
                                    Rs. 2001 to Rs. 5000                              25%
                                    Rs. 5001 to Rs. 10000                            35%
                                    Above Rs. 10000                                   50%     
     Write a program to input the total cost and to compute and display the amount to be paid by the customer after availing the discount. Three methods also their input(), calculate() and display().

Solution
import java.io.*;
/**
 * class Showroom
 *
*/
public class Showroom
{
    private double cost;    // For cost
    private double dis;     // For Discount
    private double amt;     // For Amount
    void input()throws IOException
    {
        InputStreamReader in=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(in);
        System.out.println("Enter the Cost of the product:");
        cost=Double.parseDouble(br.readLine());
    }
    void calculate()
    {
        if(cost<=2000)
          dis = cost * 0.05;
        else if(cost>2000 && cost<=5000)
          dis = cost * 0.25;
        else if(cost>5000 && cost<=10000)
          dis = cost *0.35;
        else
          dis = cost * 0.5;
        amt= cost - dis;
    }    
    void display()
    {
        System.out.println("Cost of the product="+cost);
        System.out.println("Discount given="+dis);
        System.out.println("Amount Paid="+amt);
    }
    public static void main(String args[])throws IOException
    {
        Showroom ob=new Showroom();
        ob.input();
        ob.calculate();
        ob.display();
    }
}
Output:
 Enter the Cost of the product:
5630
Cost of the product=5630.0
Discount given=1970.4999999999998
Amount Paid=3659.5

Question 8.
Write a program to enter a sentence. Calculate total Vowel, Space, Consonant, and word.

Solution.
import java.io.*;
/**
 * class SentenceCounter
 *
* Vowel, Space, Consonant  and word counter program
 */
class SentenceCounter
{
                public static void main(String args[])throws IOException
                {
                                String st="";
                                int i,l,v,c,sp;
                                char a;
                                v=c=sp=0;
                                InputStreamReader in=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(in);
                                System.out.println("Enter a sentence:");
                                st=br.readLine();
                                l=st.length();
                                for(i=0;i<l;i++)
                                {
                                                a=st.charAt(i);
                                                if(a=='a' || a=='A' || a=='e' || a=='E' || a=='i' || a=='I' || a=='o' || a=='O' || a=='u' || a=='U')
                                                 v++;
                                                 if(a==' ')
                                                  sp++;

                                }
                                c=l-(v+sp);
                                System.out.println("Total Vowel="+v);
                                System.out.println("Total Space="+sp);
                                System.out.println("Total Consonent="+c);
                                System.out.println("Total Words="+(sp+1));
                }
}

Output:
Enter a sentence:
the quick brown fox jumps over a lazy hungry dog
Total Vowel=13
Total Space=9
Total Consonent=27
Total Words=10

Question 9.
Define a class Employee having the following description :
Instance variables  :
int pan  – to store personal account number
String name – to store name
double taxIncome – to store annual taxable income
double tax – to store tax that is calculated
Member functions :
input ( ) – Store the pan number, name, taxable income
calc( ) – Calculate tax for an employee
display ( ) – Output details of an employee
Write a program to compute the tax according to the given conditions and display the output as per the given format.
Total Annual Taxable Income        Tax Rate
Upto Rs, 1,00,000                                      No tax
From 1,00,001 to 1,50,000                   10% of the income exceeding Rs. 1,00,000
From 1,50,001 to 2,50,000                   Rs. 5000 + 20% of the income exceeding Rs. 1,50,000
Above Rs. 2,50,000                                   Rs. 25,000 + 30% of the income exceeding Rs. 2,50,000
Output :
Pan Number                  Name                                    Tax-income                 Tax       
=======                    ==========                          =========                            =====
=======                    ==========                          =========                            =====
=======                    ==========                          =========                            =====

Solution
  import java.io.*;
/**
 * class Employee
 *
*
 */
class Employee
{
    // instance variables
    int pan;
    String name;
    double taxIncome, tax;

    // read the data from the keyboard
    public void input()throws IOException
    {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(in);
        System.out.println("Enter the name, pan and taxable income : ");
        name = br.readLine();
        pan = Integer.parseInt(br.readLine());
        taxIncome = Double.parseDouble(br.readLine());
       
    }

    // Method calculate tax
    public void calc()
    {
        tax = 0.0;
        if( (taxIncome > 100000) && (taxIncome <= 150000) )
          tax = (taxIncome - 100000) * 0.1;
        else if( (taxIncome > 150000) && (taxIncome <= 250000) )
          tax = 5000.0 + (taxIncome - 150000) * 0.2;
        else
          tax = 25000.0 + (taxIncome - 250000) * 0.3;
    }

    // display details of an employee
    public void display()
    {
        System.out.println("Pan Number        Name                 Tax-income         Tax");
        System.out.println(pan+"           " + name + "               " + taxIncome + "      " + tax);
    }
// Main method
    public static void main(String args[])throws IOException
    {
        Employee ob=new Employee();
        ob.input();
        ob.calc();
        ob.display();
    }
}

Output:
Enter the name, pan and taxable income :
Abdulla
20938
150000
Pan Number        Name                 Tax-income         Tax
20938                 Abdulla               150000.0      5000.0


Java program

Java program for Selection Sort

Loops in Java - Java loop explained with examples




Java program for Pronic Number

Java program for Evil Number

Neon number program in java

Java program for Evil Number



SHARE THIS
Previous Post
Next Post