ICSE Class 10 Computer Application Solved Question Paper Year 2014

(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 [ ]


Attempt all questions

Question 1

  1. Marks [2]

    Which of the following are valid comments?

    1. /*comment*/
    2. /*comment
    3. //comment
    4. */comment*/

    Ans. The valid comments are

    1. /*comment*/
    2. // comment
  2. Marks [2]

    What is meant by a package? Name any two Java Application Programming Interface packages.
    Ans. Java contains extensive library of pre-written classes that we can use in our programs. These classes are divided into groups called packages.
    There are various packages in Java, from them two Java Application Programming Interface packages are: java.applet, java.awt

  3. Marks [2]

    Name the primitive data type in Java that is:

    1. a 64-bit integer and is used when you need a range of values wider than those provided by int
    2. a single l6-bit Unicode character whose default value is ‘\u0000’.


    1. long
    2. char
  4. Marks [2]

    State one difference between the floating point literals float and double.
    Ans. Floating point real number literals:
    Single precission number float will be wtitten as: 6.02f
    Double precission number where as for double the same will be: 6.02d or even 6.02

  5. Marks [2]

    Find the errors in the given program segment and re-write the statements correctly to assign values to an integer array.
    int a = new int(5);
    for(int i=0;i<=5;i++) a[i]=i;
    Ans. Array initialization use brackets instead of parenthesis, so in the first line parenthesises are replaced with brackets. Array index starts from Zero to less than its size, so in the second line the condition of for statement will be i<5 instead i<=5.
    So the corrected program segment will be as:
    int a = new int[5];
    for(int i=0;i<5;i++) a[i]=i;

Question 2

  1. Marks [2]

    Operators with higher precedence are evaluated before operators with relatively lower precedence. Arrange the operators given below in order of higher precedence

    1. &&
    2. %
    3. >=
    4. ++

    Ans. After arranging the given operators according to the order of higher precedence the numbering list will be changed as:

    1. ++
    2. %
    3. >=
    4. &&
  2. Marks [2]

    Identify the statements listed below as assignment, increment, method invocation or object creation statements.

    1. System.out.println(“Java”);
    2. costPrice = 457.50;
    3. Car hybrid = new Car( );
    4. petrolPrice++;


    1. System.out.println(“Java”); – method invocation statement
    2. costPrice = 457.50; – assignmentstatement
    3. Car hybrid = new Car( ); – object creation statement
    4. petrolPrice++; – incrementstatement
  3. Marks [2]

    Give two differences between the switch statement and the if-else statement.
    Both switch and the if-else are conditional control statement but with the following differences (Only 2 are stated as per question):

    1. switch can test only equality but any other relational operaters can be used in if-else statement.
    2. switch supports only char, int, byte and short data type but in the case of if-else supportance are regardless of data type.
  4. Marks [2]

    What is an infinite loop? Write an infinite loop statement.
    Ans. In this case, the loop block never terminates. It is actually a kind of logical error because circumstances generally might not occur where infinite loops are required.
    An example of an infinite loop is:
    for(int i = 1; i>=0; i++)
    ; //empty statement

  5. Marks [2]

    What is a constructor? When is it invoked?
    Ans.A constructor is a Member function that automatically called, when the object created of that class. It has the same name as that of the class name and its primary job is to initialise the object to a legal value for the class.
    Constructor invoked at the time of object creation.

Question 3

  1. Marks [2]

    List the variables from those given below that are composite data types.

    1. static int x;
    2. arr[i]=10;
    3. obj.display( );
    4. boolean b;
    5. private char chr;
    6. String str;

    Ans. variables that are composite data types from the given list:

    1. arr[i]=10;
    2. String str;
  2. Marks [2]

    State the output of the following program segment:
    String str1 = “great”; String str2 = “minds”;
    System.out.println((“WH”+(str1.substring(2).toUpperCase( ))));
    Ans. grinds

  3. Marks [2]

    What are the final values stored in variables x and y below?
    double a = – 6.35;
    double b = 14.74;
    double x = Math.abs(Math.ceil(a));
    double y = Math.rint(Math.max(a,b));
    Ans. Final value of x: 6.0
    Final value of y: 15.0

  4. Marks [2]

    Rewrite the following program segment using if-else statements instead of the ternary operator.
    String grade=(mark>=90) ? “A” : (mark>=80) ? “B” : “C”;
    Ans. String grade;
    if(mark >= 90)
    grade = “A”;
    else if(mark >= 80)
    grade = “B”;
    grade = “C”;

  5. Marks [2]

    Give the output of the following method:
    public static void main(String[] args){
    int a = 5;
    a -= (a–) – (–a);
    System.out.println(a); }
    Ans. Output
    [Steps are:
    a = 5
    ie. a = a +1
    = 6 (Printed)
    a -= (a–) – (–a)
    ie. a = a – ((a–) – (–a))
    = 6 – ((6) – (4))
    = 6 – 2 = 4 (Printed)

  6. Marks [2]

    What is the data type returned by the library functions:

    1. compareTo( )
    2. equals( )


    1. Return data type of compareTo( ) is int
    2. Return data type of equals( )is boolean
  7. Marks [2]

    State the value of characteristic and mantissa when the following code is executed.
    String s = “4.3756”;
    int n = s.indexOf(‘.’);
    int characteristic = Integer.parseInt(s.substring(0,n));
    int mantissa = Integer.valueOf(s.substring(n+1);
    Ans. After executing the given code
    The value of characteristic will be: 4
    The value of mantissa will be: 3756

  8. Marks [2]

    Study the method and answer the given questions.

    public void sampleMethod( )
    		{	for(int i=0;i&lt;3;i++)
    				{	for(int j=0;j&lt;2;j++)
    					{	int number = (int)(Math.random( )*10);
    						System.out.println(number);	}}}
    1. How many times does the loop execute?
    2. What is the range of possible values stored in the variable number?


    1. The loop will execute for: Outer loop 3 times and Inner loop 2 times so, 3 x 2 =
      6 times
    2. The range of possible values stored in the variable number will be:
      0 to 9
  9. Marks [2]

    Consider the following class:
    public class myClass {
    public static int x = 3, y = 4;
    public int a = 2, b = 3; }

    1. Name the variables for which each object of the class will have its own disstinct copy.
    2. Name the variables that are common to all objects of the class.

    Ans. The variables that will be distinct to each object are:
    a and b

  10. Marks [2]

    What will be the output when the following code segments are executed?

    1. String s = “1001”;
      int x = Integer.valueOf(s);
      double y = Double.valueOf(s);
      System.out.println(“x=” +x);
      System.out.println(“y=” +y);
    2. System.out.println(“The king said \”Begin at the beginning!\” to me


    1. Output
    2. Output
      The king said “Begin at the beginning!” to me.


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 named movieMagic with the following description:
Instance variables/data members:
int year – to store the year of release of a movie
String title – to store the title of the movie
float rating – to store the popularity rating of the movie

(minimum rating = 0.0 and maximum rating = 5.0)
Member methods:

  1. movieMagic( )Default constructor to initialize numeric data members to 0 and String data member to “”.
  2. void accept( )To input and store year, title and rating.
  3. void display( )To display the title of a movie and a message based on the rating as per the table below.
Rating Message to be displayed
0.0 to 2.0 Flop
2.1 to 3.4 Semi-hit
3.5 to 4.5 Hit
4.6 to 5.0 Super Hit

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class movieMagic
	int year;
	String title;
	float rating;
	public movieMagic()
	year = 0;
	title = &quot;&quot;;
	rating = 0.0f;
	void accept( )throws IOException
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		System.out.print(&quot; Enter Movie Title: &quot;);
		title = read.readLine();
		System.out.print(&quot; Enter release year: &quot;);
		year = Integer.parseInt(read.readLine());
		System.out.print(&quot; Enter popularity rating: &quot;);
		rating = Float.parseFloat(read.readLine());
	void display()
		//if rating entered wrongly entered negative
		if (rating &lt;0.0)
			rating = 0.0f;

		if(rating &gt;= 0.0 &amp;&amp; rating&lt;=2.0)
		else if (rating &gt;= 2.1 &amp;&amp; rating &lt;= 3.4)
		else if (rating &gt;= 3.5 &amp;&amp; rating &lt;= 4.5)
			System.out.println(&quot;Super Hit&quot;);
	public static void main(String[] args) throws IOException
		movieMagic Rates = new movieMagic();


Question 5

Marks [15]

A special two-digit number is such that when the sum of its digits is added to the productof its digits, the result is equal to the original two-digit number.
Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits and product of digits = 14 + 45 = 59
Write a program to accept a two-digit number. Add the sum of its digits to the product ofits digits. If the value is equal to the number input, output the message “Special 2-digitnumber” otherwise, output the message “Not a special2-digit number”.

import java.io.*;

public class specialTwoDigit

	public static void main(String[] args)throws IOException
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		int n, d;
		int sod=0, sop=1;
		System.out.print(&quot; Input a two digit number: &quot;);
		String str = read.readLine();

		//checking if the number is 2 digit
		if(str.length() != 2)
			System.out.println(&quot; Not a 2-digit Number&quot;);
		n = Integer.parseInt(str);

		int no = n;
			d = no % 10;
			sod = sod + d;
			sop = sop * d;
			no = no / 10;
		int sum = sod + sop;
		if(sum == n)
			System.out.println(&quot; Special 2-digit&quot;);
			System.out.println(&quot; Not a special 2-digit&quot;);


Question 6

Marks [15]

Write a program to assign a full path and file name as given below. Using library functions,extract and output the file path, file name and file extension separately as shown.
Input C:\Users\adm in\Pictures\flower.jpg
Output Path: C:\Users\admin\Pictures\
File name: flower
Extension: jpg

import java.io.*;
public class filePathNameExt
	public static void main(String[] args)
		// Extraction of File Path, File Name and File Extension
		String inputPath = &quot;C:\\User\\admin\\Pictures\\flower.jpg&quot;; // One is for escape sequences and another is for String
		System.out.print(&quot; Input path is: &quot;);

		int len = inputPath.length();
		int dot = inputPath.indexOf(&quot;.&quot;); // Dot position
		int slash =inputPath.lastIndexOf(&quot;\\&quot;); //Last back slash position

		String path = inputPath.substring(0, slash); // path name is 0 to before last back slash position
		System.out.println(&quot; Path:   &quot; +path);

		String name = inputPath.substring(slash+1, dot); //name is after last back slash and upto before dot
		System.out.println(&quot; File name: &quot;  +name);

		String ext = inputPath.substring(dot+1, len); //extension is after dot till before length
		System.out.println(&quot; Extension: &quot;  +ext);


Question 7

Marks [15]

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

  1. double area(double a, double b, double c) with three double arguments, returns the area of a scalene triangle using the formula:  area = area mathematical expressionwhere s = mathematical expression
  2. double area(int a, int b, int height) with three integer arguments, returns the area of a trapezium using the formula: area = mathematical expression
  3. double area(double diagonal1, double diagonal2) with two double arguments, returns the area of a rhombus using the formula: area = mathematical expression


import java.io.*;
public class overloadArea
	double resultantArea;
	public overloadArea()
		resultantArea = 0.0;
    //Area of a scalene triangle
	double area(double a, double b, double c)
		double s = ( a + b + c ) / 2;
		resultantArea = Math.sqrt(s * (s - a) * (s - b) * (s - c));
		return resultantArea;
	//Area of a trapezium
	double area(int a, int b, int height)
		resultantArea =  (height * (a + b))/2;
		return resultantArea;
	//Area of a rhombus
	double area(double diagonal1, double diagonal2)
		resultantArea = ( diagonal1 * diagonal2) / 2;
		return resultantArea;
	public static void main(String[] args)
		overloadArea doArea = new overloadArea();

		double triangle = doArea.area(18.0, 16.0, 12.0);
		double trapiziun = doArea.area(12, 8, 14);
		double rhombus = doArea.area(18.0, 22.0);

		System.out.println(&quot;Area of a scalene triangle: &quot; +triangle);
		System.out.println(&quot;Area of a trapezium: &quot; +trapiziun);
		System.out.println(&quot;Area of a rhombus: &quot; +rhombus);

Question 8

Marks [15]

Using the switch statement, write a menu driven program to calculate the maturity amountof a Bank Deposit.
The user is given the following options:

  1. Term Deposit
  2. Recurring Deposit

For option (i) accept principal(P), rate of interest(r) and time period in years(n). Calculateand output the maturity amount(A) receivable using the formula

A =  maturity amount

For option (ii) accept Monthly Installment (P), rate ofinterest(r) and time period in months(n). Calculate and output the maturity amount(A) receivable using the formula

A = maturity amount

For an incorrect option, an appropriate error message should be displayed.


import java.io.*;
import java.io.*;

public class bankDeposite
    public static void main(String[] args)throws IOException
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        int p = 0, n = 0;
        double a = 0.0;
        double r = 0.0;
        System.out.println(&quot; MENU:-&quot;);
        System.out.println(&quot; TERM DEPOSIT: PRESS 1&quot;);
        System.out.println(&quot; RECURRING DEPOSIT: PRESS 2&quot;);
        System.out.print(&quot; Enter your choice: &quot;);
        int ch = Integer.parseInt(read.readLine());

            case 1:
            System.out.print(&quot; Enter Principal Amount: &quot;);
            p = Integer.parseInt(read.readLine());
            System.out.print(&quot; Enter rate of interest: &quot;);
            r = Integer.parseInt(read.readLine());
            System.out.print(&quot; Enter time period in years: &quot;);
            n = Integer.parseInt(read.readLine());
            a = p * Math.pow((1 + r/100),n);

            case 2:
            System.out.print(&quot; Enter Monthly Installment: &quot;);
            p = Integer.parseInt(read.readLine());
            System.out.print(&quot; Enter rate of interest: &quot;);
            r = Integer.parseInt(read.readLine());
            System.out.print(&quot; Enter time period in months: &quot;);
            n = Integer.parseInt(read.readLine());
            a = p * n + p * n*(n+1)/2 * r/100 * 1/12;

            System.out.println(&quot; Sorry Entered Wrong Choice, Hence &quot;);
        System.out.print(&quot; Maturity Amount is &quot; +a);

Question 9

Marks [15]

Write a program to accept the year of graduation from school as an integer value from theuser. Using the Binary Search technique on the sorted array of integers given below,output the message “Record exists” if the value input is located in the array. Ifnot, outputthe message “Record does not exist”.
{1982, 1987, 1993, 1996, 1999, 2003, 2006, 2007, 2009, 2010}

import java.io.*;

public class BsearchGraduateYear

	public static void main(String[] args)throws IOException
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		int year[] = {1982, 1987, 1993, 1996, 1999, 2003, 2006, 2007, 2009, 2010};

	    System.out.print(&quot; Enter Year of Graduation: &quot;);
	    int y = Integer.parseInt(read.readLine());
	    int ub = 9;
	    int lb = 0;
	    int mid; 

	    boolean flag = false;
			mid = ( ub + lb )/2;
				if ( y == year[mid])
					System.out.println (&quot; Year is: &quot; +year[mid] );
					System.out.println (&quot; Found at index: &quot; +mid );
					System.out.println (&quot; Position in list: &quot; +( mid + 1 ) );
					flag = true;
				else if( y &lt; year[mid] )
					ub = mid - 1;
					lb = mid + 1;
		while( lb &lt;= ub );
			if(flag == false)
				System.out.print ( &quot; Record does not exist&quot; );


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.