ICSE Class 10 Computer Application Solved Question Paper Year 2010


COMPUTER APPLICATIONS ICSE – 2010
(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]

    Define the term Byte code.
    Ans. Byte code: Byte code is a machine instruction for Java processor chip called Java virtual machine (J.V.M). The byte code is independent of computer system it has to run upon. The byte codes are always exactly the same irrespective of the computer system they are to execute upon.

  2. Marks [2]

    What do you mean by type conversion?
    How is implicit conversion different from explicit conversion?
    Ans. Type conversion: The process of converting one predefined type into another is called Type conversion. It is of two types:

    1. Implicit
    2. Explicit

    Implicit conversion is performed by compiler without programmers’ intervention but explicit is performed by user that forces an expression to the specify type.
    Eg. (type) conversion
    Where type: is a valid data type in which conversion is to be done.

  3. Marks [2]

    Name two jump statements and their use.
    Ans. Two jump are statements are

    1. Break: It skips the rest of loop and jumps over the statement following the loop,
    2. Continue: It skips the rest of the loop statement and causes the next iterations of the loop.
  4. Marks [2]

    What is an Exception? Name two Exception handling blocks.
    Ans. Exception: Contradicting or unexpected situation or unexpected errors during program execution is called Exception
    Two exceptions handle blocks are:

    1. try block and
    2. catch block
  5. Marks [2]

    Write two advantages of using functions in a program.
    Ans. Two advantages of using functions.

    1. To allow us to cope with complex problems,
    2. To hide low level details that otherwise obscure and confuse,
    3. To use portion of code.

Question 2

  1. Marks [2]

    State the purpose and return data type of the following String functions:

    1. indexOf( )
    2. compareTo( )

    Ans.

    1. IndexOf(): It searches for the first occurrence of a character or sub-string return data type will be integral.
    2. CompareTo(): It sort the given string. Return data type will be integer.
  2. Marks [2]

    What is the result stored in x, after evaluating the following expression
    int x = 5; x = x++ *2 + 3* –x;
    Ans. x = 5,
    Then x,
    = x++ *2+3*–x,
    = 5*2+3*(5)
    = 10+15
    = 25

  3. Marks [2]

    Differentiate between static and non – static data members
    Ans. Static: static data members can be accessed before any objects of its class are created and without reference to any object. While non-static data members do not provide such facility.

  4. Marks [2]

    Write the difference between length and length( ) functions.
    Ans. length(): it is used to obtain number of character contained in string.
    length: length is used to depict size of an array that is number of elements an array can hold.

  5. Marks [2]

    Private: It means that the methods in same class are permitted to use this method.
    Protected: It means that methods in this class and methods in any subclasses may use this method.

Question 3

  1. Marks [2]

    What do you understand by the term data abstraction? Explain with an example.
    Ans. Data Abstraction: It refers to the act of representing essential features without including back ground details or explanation.
    Example: While driving a car, you know only essential features e.g. gear handling, steering handling etc. but without knowing the internal details. This is abstraction.

  2. Marks [2]

    What will be the output of the following code?

    1. int m = 2;
      int n = 15;
      for(int i = 1 ; i<5; i++);
      m++;
      –n;
      System.out.println(“m = ” +m);
      System.out.println(“n = ” +n);
    2. char x = ‘A’;
      int m;
      m = (x == ‘a’)? ‘A’:’a’;
      System.out.println(“m = ” +m);

    Ans.

    1. m = 3
      n = 14
    2. m = 97
  3. 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 k = l, i = 2;
    while( ++i<6 )
    k *= i;
    System.out.println(k);
    Ans. 60

  4. Marks [2]

    Give the prototype of a function check which receives a character ch and an integer n and returns true or false.
    Ans. boolean check(char ch, int n)

  5. Marks [2]

    State two features of a constructor.
    Ans. Constructor:

    1. Constructor name has the same name as the class it belongs to. While initializing Object its get automatically initialized.
    2. Constructor prototype does not have any return type or even void, since constructors never return a value.
  6. Marks [2]

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

    1. Extract the second last character of a word stored in the variable wd.
    2. Check if the second character of a string str is in uppercase.

    Ans.

    1. String wd = “abcdef”;
      int len = wd.length();
      char c = wd.charAt(len-2);
    2. String str = “aBcdef”;
      int len = str.length();
      char c = str.charAt(1); //Extracting 2nd character
      boolean chk = Character.isUpperCase(c);//Checking the character is in Upper case
  7. Marks [2]

    What will the following functions return when executed?

    1. Math.max(-17, -19)
    2. Math.ceil(7.8)

    Ans.

    1. -17,
    2. 8
  8. Marks [2]
    1. Why an object is called an instance of a class?
    2. What is the use of the keyword import?

    Ans.

    1. Object is called an instance of class as it is used to represent different methods and data members of the class
    2. import is used to include the package in our program.
      Example:

      import java.io.*;
      

      It means java.io. Package will be included in the program.

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]

Write a program to perform binary search on a list of integers given below, to search for an element input by the user, if it is found display the element along with its position, otherwise display the message “Search element not found” 5,7,9,11,15,20,30,45,89,97
Ans.

import java.io.*;
class Binary
{
public static void main( ) throws IOException
{
//array elements are in ascending order
BufferedReaderbuf = new BufferedReader( new InputStreamReader(System.in));
int x[ ] = {5,7,11,15,20,30,45,89,97};
System.out.print( "Enter element to search in the list ");
int elem = Integer.parseInt( buf.readLine( ) );
//Intitialise lower bound and upper bound
int LB = 0, UB = 9 ; // 10 elements, so UB = 9
int mid = 0;
boolean flag = false;
do
{
mid = ( LB + UB )/2;
if ( elem ==x [mid])
{
System.out.println (" Element is: "+ elem);
System.out.println (" Found at index: "+ mid);
System.out.println (" Position in list: "+ ( mid+1 ) );
flag = true;
break;
}
else if( elem <x [mid] )
{
UB = mid - 1;
}
else
LB = mid +1;
}
while( LB <= UB );
if(flag == false)
System.out.print ( "Search element not found" );
}
}

Question 5

Marks [15]

Define a class student described as below:
Data members/instance variables:
Name, age, ml, m2, m3 (marks in 3 subjects), maximum, average
Member Methods:

  1. A parameterized constructor to initialize the data members
  2. To accept the details of a student
  3. To compute the average and the maximum out of three marks
  4. To display the name, age, marks in three subjects, maximum and average.

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

import java.io.*;
class student
{
String name;
int age, ml , m2, m3;
int maximum;
int average;
public student(String Name,int Age,int M1,int M2,int M3)
{
name = Name;
age = Age;
ml = M1;
m2 = M2;
m3 = M3;
maximum = 0;
average = 0;
}
public void accept( )
{
name = "Avishek Mitra";
age = 14;
ml = 95;
m2 = 80;
m3= 78;
}
public void compute( )
{
average = ( ml + m2 + m3)/3;
if (ml>m2 && ml>m3)
maximum = ml;
else if (m2>ml && m2 >m3)
maximum = m2;
else
maximum = m3;
}
public void display()
{
System.out.println("Name of student is: " + name);
System.out.println("Age is: " + age);
System.out.println("Marks in 1st subject: " + ml);
System.out.println("Marks in 2nd subject: " + m2);
System.out.println("Marks 3rd subject: " + m3);
System.out.println("Maximum marks: " + maximum);
System.out.println("Average is: " + average);
}
public static void main(String args[ ])
{
student s = new student("Koneenika",7,82,66,91);
System.out.println("Using Parameterised Constructor:-");
s.compute( );
s.display( );
System.out.println("Using a method to accept:-");
s.accept( );
s.compute( );
s.display( );
}
}

Question 6

Marks [15]

Shasha Travels Pvt. Ltd. gives the following discount to its customers:

Write a program to input the name and ticket amount for the customer and calculate the discount amount and net amount to be paid. Display the output in the following format for each customer:
SL. No. Name Ticket charges Discount Net amount
1. – – – –
(Assume that there are 15 customers, first customer is given the serial no (SI. No.) 1, next customer2 and so on)
Ans.

import java.io.*;
class ShashaTravels
{
public static void Bill(String Name[], int TicketCharges[])
{
double discount;
double NetAmount;
for(int i = 0; i<15; i++)
{
if(TicketCharges[i] < 25001)
discount = 0.02 * TicketCharges[i];
else if (TicketCharges[i] > 25001 && TicketCharges[i] < 3500)
discount = 0.1 * TicketCharges[i];
else if (TicketCharges[i] >35001 && TicketCharges[i] <5500)
discount = 0.12 * TicketCharges[i];
else if (TicketCharges[i] >55001 && TicketCharges[i] < 7000)
discount = 0.16 * TicketCharges[i];
else
discount = 0.18 * TicketCharges[i];
NetAmount = TicketCharges[i] - discount;
System.out.println((i+1)+"\t" +Name[i]+"\t\t" +TicketCharges[i]+"\t\t" +discount+"\t\t" +NetAmount);
}
}
public static void main(String args[])throws IOException
{
InputStreamReader br = new InputStreamReader(System.in);
BufferedReader read = new BufferedReader(br);
String n[] = new String[15];
int TC[] = new int[15];
for(int i = 0; i<15; i++)
{
System.out.print("Enter Name for customer " +(i+1) +" ");
n[i] = read.readLine();
System.out.print("Enter Ticket Charges: ") ;
TC[i] = Integer.parseInt(read.readLine());
}
System.out.println("SL. No." +"\tName" +"\tTicket charges" +"\tDiscount" +"\tNet Amount");
Bill(n,TC);
}
}

Question 7

Marks [15]

Write a menu driven program to accept a number and check and display whether it is a Prime number or not OR an Automorphic number or not. (Use switch – case statement)

  1. Prime number: A number is said to be a prime number if it is divisible only by 1 and itself and not by any other number.
    Example: 3, 5, 7, 11, 13 etc.
  2. Automorphic number: An Automorphic number is the number which is contained in the last digit(s) of its square.
    Example 25 is an Automorphic number as its square id 625 and 25 is present as the last twodigits.

Ans.

import java.io.*;
class PrimeAutomorphic
{
public static void main(String args[])throws IOException
{
InputStreamReader reads = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(reads);
int choice, n;
System.out.print("Enter a number: ");
n = Integer.parseInt(br.readLine());
System.out.println("Your Choices:-");
System.out.println("Menu");
System.out.println("1 - Prime");
System.out.println("2 - Automorphic");
System.out.print("Enter your choice: ");
choice = Integer.parseInt(br.readLine());
switch (choice)
{
case 1:
//to check given no is Prime or not.
int c = 0, i;
for (i = 2; i<n; i++)
{
if(n % i == 0)
{
c++;
break;
}
}
if(c == 0)
System.out.println("No. is Prime");
else
System.out.println("No. is not prime");
break;
case 2:
//to check given no is Automorphic or not.
int no = 0, sq = 0, a = 0, rs = 0, rn = 0;
sq = n * n;
no = n;
while(n>0)
{
rs = sq%10;
sq = sq/10;
rn = n%10;
n = n/10;
}
if (rs == rn)
System.out.println("No. is Automorphic");
else
System.out.println("No. is not Automorphic");
break;
default:
System.out.println("Nothing to do with the Number - Invalid option Choosen");
}
}
}

Question 8

Marks [15]

Write a program to store 6 elements in an array P, and 4 elements in an array Q and produce a third array R, containing all the elements of array P and Q. Display the resultant array.
EXAMPLE INPUT

P[6] Q[4] OUTPUT R[10]
4 19 4
6 23 6
1 7 1
2 8 2
3 3
10 10
19
23
7
8

Ans.

import java.io.*;
class arrayMerge
{
public static void main(String args[])throws IOException
{
int i, j = 0, k = 0;
int[ ] P = {4,6, 1,2, 3, 10};
int[ ] Q = {19,23,7,8};
int[ ] R = new int [10];
for (i = 0; i < R.length; i++)
{
if(j<P.length)
{
R[i] = P[j];
j++;
}
else
{
R[i] = Q[k];
k++;
}
}
for (i = 0; i < R.length; i++)
System.out.println(R[i]);
}
}

Question 9

Marks [15]

Write a program to input a string in uppercase and print the frequency of each character.
Example:
INPUT: COMPUTER HARDWARE
OUTPUT:

CHARACTERS FREQUENCY
A 2
C 1
D 1
E 2
H 1
M 1
O 1
P 1
R 3
T 1
U 1
W 1

Ans.

import java.io.*;	
public class Frequency
{
public static void main(String[] args)throws IOException
{
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a string: ");
String str = buf.readLine( );
int c;
str = str.toUpperCase();
System.out.println("Character\t\tFrequency");
for(int i = 65; i<=92; i++)
{
c = 0;
for(int j = 0; j<str.length(); j++)
{
if((char)(i) == str.charAt(j))
{
c += 1;
}
}
if(c > 0)
System.out.println((char)(i) +"\t\t\t" +c);
}
}
}

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.