ICSE Class 10 Computer Application Solved Question Paper Year 2011


COMPUTER APPLICATIONS ICSE – 2009
(Theory)
(Two Hours)

Answer to this paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 minutes.
This time is to be spent in reading the question paper.
The time given on the head of this paper is the time allowed for writing the answer.
This Paper is divided into Sections.
Attempt all questions from Section A and any four from Section B.
The intended marks for questions or parts of questions are given in brackets [ ]

SECTION A (40 MARKS)

Attempt all questions

Question 1

  1. Marks [2]

    What is the difference between an object and a class?
    Ans. Object is a unique entity, which contains data and functions (characteristics and behaviour) whereas the class is a set of similar objects. Each object of a class possesses same attributes and common behaviour defined within the same class.

  2. Marks [2]

    What does the token ‘keyword’ refer to, in the context of Java?
    Give an example for keyword.
    Ans. Keywords are the words that convey a special meaning to the language compiles. These are reserved for special purpose.
    eg:- boolean, break, byte, etc.

  3. Marks [2]

    State the difference between entry controlled loop and exit controlled loop
    Ans.

    Entry controlled loop Exit controlled loop
    Point 1 This loop will not execute at all if the condition is not satisfied This loop will execute at least once
    Point 2 This loop checks the condition first and then Execution begins. This loop checks the condition after executing the loop over
    E.g. for( ; ; ) AND while( ) do while( )
  4. Marks [2]

    What are the two ways of invoking functions?
    Ans. The two ways of invoking functions are:-

    1. Pass by value
    2. Pass by reference
  5. Marks [2]

    What is the difference between / and % operator?
    Ans.

    ‘/’ operator ‘%’ operator
    The ‘/’ operator divides its first operand by the second. The ‘%’ operator finds the Modulus of its first operand relative to the second. That is it produces Reminder of dividing the first by the second operand.
    e.g.:- 100/5 evaluate to 20 e.g.:- 19/6 evaluate to 1

Question 2

  1. Marks [2]

    State the total size in bytes, of the arrays a[4] of char data type and p[4] of float data type.
    Ans. The total size of char a[4] in bytes is 2 x 4 = 8 bytes the total size of float p[4] in bytes is 4 x 4 = 16 bytes.

  2. Marks [2]
    1. Name the package that contains Scanner class.
    2. Which unit of the class gets called, when the object of the class is created?

    Ans.

    1. The package that contains the Scanner class is Java.util.
    2. Constructor gets called, when the object of the class is created.
  3. Marks [2]

    Give the output of the following:
    String n = “Computer Knowledge.”;
    String m = “Computer Applications”;
    System.out.println(n.substring(0,8).concat(m.substring(9)));
    System.out.println(n.endsWith(“e”));
    Ans. The output is:-
    Computer Applications.
    False

  4. Marks [2]

    Write the output of the following:

    1. System.out.println(Character.isUpperCase(R));
    2. System.out.println(Character.toUpperCase(j));

    Ans.

    1. The output is:-
      True
    2. The output is:-
      J
  5. Marks [2]

    What is the role of keyword void in declaring function?
    Ans. Void specifies an empty set of values and it is used as the return type for functions that do have any returns.

Question 3

  1. Marks [2]

    Analyse the following program segment and determine how many times the loop will be executed and what will be the output of the program segment?

    int p = 200;
    while (true)
    {
    if(p<100)
    break;
    p = p-20;
    }
    System,out.println(p);
    

    Ans. The loop will continue for 7 times
    And the output is:-80

  2. Marks [2]

    What will be the output of the following code?

    1. int k = 5, j=9;
      k += k++ – ++j + k;
      System.out.println(“k = ” +k);
      System.out.println(“j = ” +j);
    2. double b =-15.6;
      double a = Math.rint(Math.abs(b));
      System.out.println(” a = ” +a);

    Ans.

    1. The output is:-
      k = 6
      j = 10
    2. The output is:-
      a = 16.0
  3. Marks [2]

    Explain the concept of constructor overloading with an example.
    Ans. A function without return type and having same name that of class name is called constructor. A class having constructor with several definitions under the same scope that are differentiable by the number and types of their arguments, is said to be an overloaded constructor.
    Example:-

    public class Area
    {
    int a;
    int b;
    public Area( ) // Default Constructor, having no Argument
    {
    a = 0;
    b = 0;
    }
    public Area(int s1 )// Parameterized Constructor 1, having single Integer Argument
    {
    a = s1;
    }
    public Area(int s1, int s2 )// Parameterized Constructor 2, having two Integer Arguments
    {
    a = s1;
    b = s2;
    }
    
    
    }
    
  4. Marks [2]

    Give the prototype of a function search which receives a sentence sentnc and a word wrd and returns 1 or 0?
    Ans. public int search(String sentnc, string wrd)

  5. Marks [2]

    Write an expression in Java for

    mathematical expression

    Ans. double z = (5 * x * x * x * + (2 * y))/(x + y);

  6. Marks [2]

    Write a statement each to perform the following task on a string:

    1. Find and display the position of the last space in a string s.
    2. Convert a number stored in a string variable x to double data type.

    Ans.

    1. int n = s.lastindexOf( );
    2. double d = Double.parseDouble (x);
  7. Marks [2]

    Name the keyword that

    1. Informs that an error has occurred in an input/output operation.
    2. Distinguishes between instance variables and class variables.

    Ans.

    1. catch or throws keyword inform that an error has occurred in an input/output operation
    2. A class variable is visible / usable to all method within that class.A instance variable is only visible/usable within the method (instance) that it has been declared in.
  8. Marks [2]

    What are library classes? Give an example.
    Ans. Java includes predefined classes in the form of package, called Java library classes.
    e.g.:- String class, StringBuffer class etc.

  9. Marks [2]

    Write one difference between Linear Search and Binary Search.
    Ans.

    Linear Search Binary search
    In linear search, each Element of the array Is composed with the Given item to be searched for, one by one Binary search searches for the given item after segmented the array into two parts. The search segment reduces to half at every successive stage.

SECTION B (60 MARKS)

Attempt any four questions from this Section.
The answers in this Section should consist of the Programs in either Blue J
environment or any program environment with Java as the base.
Each program should be written using Variable description/Mnemonic Codes
so that the logic of the program is clearly depicted.
Flow-Charts and Algorithms are not required.

Question 4

Marks [15]

Define a class called mobike with the following description:
Instance variables/data members:
int bno – to store the bike’s number
int phno – to store the phone number of the customer
String name – to store the name of the customer
int days – to store the number of days the bike is taken on rent
int charge – to calculate and store the rental charge
Member methods:
void input( ) – to input and store the detail of the customer
void compute( ) – to compute the rental charge.
The rent for a mobike is charged on the following basis:
First five days `500 per day.
Next five days `400 per day.
Rest of the days `7200 per day.
void display( ) – to display the details in the following format:
Bike No. Phone No. Name No. of days Charge

Ans.

import java.io.*;
class mobike
{
int bno;
int phno;
String name;
int days;
int charge;
mobike( )
{
int bno = 0;
int phno = 0;
String name = "";
int days = 0;
int charge = 0;
}
public void input( ) throws IOException
{
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader input = new BufferedReader(read);
System.out.print("Enter custimer name: ");
name = input.readLine( );
System.out.print("Enter Bike No.: ");
bno = Integer.parseInt(input.readLine());
System.out.print("Enter Phone No.: ");
phno = Integer.parseInt(input.readLine( ));
System.out.print("Enter Days of rent: ");
days = Integer.parseInt(input.readLine( ));
}
public void compute( )
{
if(days<5)
charge = 500 * days;
else if(days<=10)
charge = 5 * 500 + (days - 5) * 400;
else
charge = 5 * 500 + 5 * 400 + (days - 10) * 200;
}
public void display( )
{
System.out.println("Bike No " +" Phone No " +"\tName " +" \tNo of days " +" \tCharge ");
System.out.println(bno +""+phno +"\t"+name +"\t\t"+days +"\t"+charge);
}
public static void main(String args[]) throws IOException
{
int bno, phno, days, charge = 0;
String name;
mobike Obj = new mobike();
Obj.input( );
Obj.compute( );
Obj.display( );
}
}

Question 5

Marks [15]

Write a program to input and store the weight of ten people. Sort and display them in descending order using the selection sort technique.
Ans.

import java.io.*;
class weight
{
public static void main (String args [ ]) throws IOException
{
InputStreamReader read = new InputStreamReader (System.in);
BufferedReader input = new BufferedReader (read);
int i, j, small,temp;
int W[] = new int[10];
String v;
for(i = 0; i<10; i++)
{
System.out.print("Enter weight of ten people: people No. " +(i+1) +": ");
W[i] = Integer.parseInt(input.readLine ( ));
}
for(i = 0; <10; i++)
{
small = i;
for(j = i; j<10; j++)
{
if(W[j] < W[small])
{
small = j;
}
temp = W[i];
W[i] = W[small];
W[small] = temp;
}
}
System.out.println("Weight of ten people in descending order is - >");
for(i = 0; i<10; i++)
System.out.println("Weight of people: At " +(i+1) +" is " +W[i]);
}
}

Question 6

Marks [15]

Write a program to input a number and print whether the number is a special number or not.
(A number is said to be a special number, if the sum of the factorial of the digits of the number is same as the original number).
Example: 145 is a special number, because l! + 4! + 5! = 1+24+120 = 145
(Where ! stands for factorial of the number and the factorial value of a number is the product of all integers from 1 to that number, example 5! = 1*2*3*4*5 = 120).
Ans.

import java.io.*;
class SpecialNumber
{
public static void main (String args [ ]) throws IOException
{
InputStreamReader read = new InputStreamReader (System.in);
BufferedReader input = new BufferedReader (read);
int m,n,p,d,q,s,i,f;
q = 0;
f = 1;
s = 0;
System.out.print (" Enter your Number: ");
n = Integer.parseInt(input.readLine( ));
m = n;
while (m != 0)
{
q = m / 10;
p = q * 10;
d = m - p;
System.out.println (" The digit is: " +d);
for(i = 1; i <= d; i++)
f = f * i;
s = s + f;
m = m/10;
f = 1;
}
System.out.println(" The value of sum of factorial of digit is = " +s);
if(s == n)
System.out.println(" Hence the No. is a Special Number");
else
System.out.println(" Hence the no. is not a Special Number");
}
}

Question 7

Marks [15]

Write a program to accept a word and convert into lowercase if it is in uppercase, and display the new word by replacing only the vowels with the character following it.
Example:
Sample Input : computer
Sample Output : cpmpvtfr
Ans.

class wordChange
{
public static void main (String args [ ]) throws IOException
{
InputStreamReader read = new InputStreamReader (System.in);
BufferedReader input = new BufferedReader (read);
int len, i ;
char ch = ' ';
String slwr = "";
String slwrchange = "";
System.out.print("Enter a word: ");
String str = input.readLine( );
len = str.length( );
//Fetching only the 1st Word if entered string is a sentence
for(i = 0; i<len; i++)
{
ch = str.charAt(i);
if(ch == ' ')
break;
slwr = slwr + ch;
}
//Converting the word into lower case
slwr = slwr.toLowerCase( );
len = slwr.length( );
for(i=0;i<len; i++)
{
ch = slwr.charAt(i);
System.out.println(ch);
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
{
ch = (char)(ch + 1);
}
slwrchange = slwrchange + ch;
}
System.out.print(slwrchange);
}
}

Question 8

Marks [15]

Design a class to overload a function compare( ) as follows:

  1. void compare(int, int) – to compare two integer values and print the greater of the two integers.
  2. void compare(char, char) – to compare the numeric value of two characters and print the character with higher numeric value.
  3. void compare (String, String) – to compare the length of the two strings and print the longer of the two.

Ans.

import java.io.*;
class CompareFunction
{
public static void compare (int a, int b)
{
if(a>b)
System.out.println ("Greater No. is " +a);
else
System.out.println ("Greater No. is " +b);
}
public static void compare (char ch1, char ch2)
{
if((int)ch1 > (int)ch2)
System.out.println ("Character with a higher numeric value: " +ch1);
else
System.out.println ("Character with a higher numeric value: " +ch2);
}
public static void compare (String stl, String st2)
{
int len1 = stl.length( );
int len2 = st2.length( );
if(len1 > len2)
{
System.out.println ("Longer string is = " +stl);
System.out.println ("Longer string is = " +len1);
}
else
{
System.out.println ("Longer string is = " +st2);
System.out.println ("longer string is = " +len2);
}
}
public static void main (String args [ ]) throws IOException
{
InputStreamReader read = new InputStreamReader (System.in);
BufferedReader input = new BufferedReader (read);
intx, y;
charc1, c2;
String s1, s2;
System.out.println("To print the greater of the two integers:-");
System.out.print("Enter 1st Number: ");
x = Integer.parseInt(input.readLine( ));
System.out.print("Enter 2nd Number: ");
y = Integer.parseInt(input.readLine( ));
compare(x, y);
System.out.println("To print the higher numeric value of two character:-");
System.out.print("Enter 1st Character: ");
c1 = (char)input.read ( );
input.readLine();//Flushing /r and /n Characters
System.out.print("Enter 2nd Character: ");
c2 = (char)input.read( );
input.readLine();//Flushing /r and /n Characters
compare (c1, c2);		
System.out.println("To print the longer of the two sentence:-");
System.out.print("Enter 1st string: ");
s1 = input.readLine ( );
System.out.print("Enter 2nd string: ");
s2 = input.readLine ( );
compare (s1, s2);
}
}

Question 9

Marks [15]

Write a menu driven program to perform the following: (Use switch-case statement)

  1. To print the series 0, 3, 7, 15, 24 … n terms (value of n is to be an input by the user)
  2. To find the sum of the series given below:
    S = 1/2 + 3/4 + 5/6 + 7/8..19/20.

Ans.

import java.io.*;
import java.math.BigDecimal;
class Series
{
public static void main (String args [ ]) throws IOException
{
InputStreamReader read = new InputStreamReader (System.in);
BufferedReader input = new BufferedReader (read);
int ch, n, i, se;
double s = 0.0;
System.out.println ("MENU");
System.out.println (" 1.0, 3, 7, 15, 24,   n");
System.out.println (" 2.1/2 + 3/4 + 5/6 +  + 19/20");
System.out.print (" Enter your choice: ");
ch = Integer.parseInt(input.readLine( ));
switch(ch)
{
case 1:
System.out.print (" Enter a number: ");
n = Integer.parseInt(input.readLine( ));
for(i = 1; i <= n; i++)
{
if(i%3 == 0)
se = (i*i) - 2;
else
se = (i*i) - 1;
System.out.print(se +", ");
}
break;
case 2:
for(i = 1; i <= 19; i += 2)
{
s = s + (double)i/(i+1);
}
//Setting up precission ro four decimal point
BigDecimal four = new BigDecimal(s).setScale(4,BigDecimal.ROUND_HALF_UP);
s = four.doubleValue();
System.out.println (" Sum of the series is: " +s);
break;
default:
System.out.println (" Wrong choice entered ");
}
}
}

Add a Comment

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.