ICSE Class 10 Computer Application Solved Question Paper Year 2007

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

    Name two types of Java programs.
    Ans. The two types of Java programs are :

    1. Stand Alone Applications: It is a program that runs on a computer system under its operating system i.e., it can run on any platform.
    2. Internet Applets: It is a program that runs within a web browser. Thus, applets are applications which are designed to be transmitted over the Internet and executed by a Java compatible web browser.
  2. Marks [2]

    Define Instance Variable. Give an example of the same.
    Ans. Variables denned within a class are called instance variables because each instance of the class (that is, each object of the class) contains its own copy of these variables. Thus, the data for one object is separate and unique from the data for another.

    		class Box
    				double width;
    				double height;
    				double depth;
    			class Box Demo2
    				public static void main(String args[ ])
    					Box mybox1 = new Box ();
    					Box mybox2 = new Box ();
    					double vol;
    					myboxl.width =10;
    					myboxl.height = 20;
    					myboxl.depth =15.;
    					mybox2. width = 3;
    					mybox2 .height = 6;
    					mybox2.depth = 9;
    					Vol = myboxl.width * myboxl.height * myboxl.depth;
    					System.out.println("Volume is " +vol);
    					Vol = mybox2.width * mybox2.height * mybox2.depth;
    					System.out.println("Volume is " +vol);
                    In the above program, we can see that the object myboxl has the following three instance
    		Similarly, the object mybox2 has the following three instance variables:
  3. Marks [2]

    Differentiate between Binary Search and Linear Search.
    Ans. Linear Search:

    1. This search technique works both for sorted and unsorted arrays.
    2. The linear search technique performs a very large number of comparisons and hence consumes a lot of time when the element to be searched is one of the last elements of the array.
      Binary Search:

      1. This search technique can work only for sorted arrays.
      2. The technique performs fewer comparisons and hence saves time. It is more efficient than linear search technique in case of larger arrays.
  4. Marks [2]

    Assign the value of pie (i.e., 3.142) to a variable with requisite data type.
    Ans. double pi;
    pi = 3.142;

  5. Marks [2]

    Explain with an example the if-else -/f construct.
    Ans. The if-else-if construct is a common programming construct that is based upon a sequence of nested ifs.
    It looks like this:
    else if(condition)
    else if(condition)
    The if statements are executed from the top down. As soon as one of the conditions controlling the if is true, the statement associated with that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then the final else statement will be executed. The final else acts as a default condition; that is, if all other conditional tests fail, then the last else statement is performed. If there is no final else and all other conditions are false, then no action will take place.

    		   class IfElse
    			public static void main (String args[ ])
     				int month = 4; // April
     				String season;
    				if(month == 12 || month == 1 || month == 2)
    					season = "Winter";
    				else if(month == 3 || month == 4 || month ==5)
    					season = "Spring";
     				else if (month == 6 || month == 7 || month ==8)
    					season = "Summer";
    				else if (month == 9 || month == 10 || month == 11)
     					season = "Autumn";
    					season = "Bogus Month";
    				System.out.println("April is in the " +season +".");
    		            The above program produces the following output:
    		            April is in the Spring.

Question 2

  1. Marks [2]

    Differentiate between Format Parameter and Actual Parameter.
    Ans. Formal parameter: Parameters which appear in function prototype i.e., function definition are called ‘formal parameters’ of a function.
    Actual parameter: Parameters which appear in function call statement are called ‘actual parameters’ of a function.
    For example:

    	        public static int area(int a, int b)
    			return a * b;
    		public static void displayArea()
    			int length = 10;
    			int width = 15;
    			int area = area(length, width);
    		In the above code snippet; a and b are formal parameters whereas length and width are actual
  2. Marks [2]

    Why do we need a constructor as a class member?
    Ans. A constructor is a member function whose task is to initialize the objects of its class. It is invoked whenever an object of its class is created. That’s why we need a constructor as a class member.

  3. Marks [2]

    Explain the term typecasting,
    Ans. Type casting: The explicit conversion of an operand to a specific type is called type casting.
    Type casting in Java is done as shown below:
    (type) expression
    Where type is a valid Java data type to which the conversion is to be done.
    For example, to make sure that the expression ( x +y/2) evaluates to type float, we write it as:
    Another example:
    int a; byte b;
    b = (byte)a;
    The above fragment casts an int to a byte.

  4. Marks [2]

    Name the following:

    1. A package that is invoked by default.
    2. A key word, to use the classes defined in a package.


    1. A package that is invoked by default: Java.lang
    2. A keyword, to use the classes defined in a package: import
  5. Marks [2]

    Name the class that is used for different mathematical functions. Give an example of a mathematical function.
    Ans.Math class is used for different mathematical functions.
    Example of a mathematical function :
    sin(x): This function returns the sine of the angle x in radians .
    sqrt(x) : This function returns the square root of x.
    pow(x, y) : This function returns x raised to y (xy).
    log(x): This function returns the natural logarithm of x.

Question 3

  1. Marks [2]

    State the difference between = and ==.
    Ans. = Stands for “assignment” operator == Stands for “equal to” operator i.e., == is a relational operator which tests for equality.
    For example:
    Value == 10
    The above expression tests whether value is equal to 10. This expression has the boolean value tn if the comparison is true and boolean false if it is false.
    Value = 10
    The above expression assigns 10 to value. The whole expression, in this case, has the value 10 because that’s the value of the left hand side.

  2. Marks [2]

    Write an equivalent Java syntax for the following expression:

    Ans. Given expression:

    Equivalent Java syntax:
    a = (0.05 – (2 * Math.pow(y, 3))) / (x-y)

  3. Marks [2]

    Rewrite the following using Ternary operator
    if (income < = 10000)
    tax = 0;
    tax = 12;
    Ans. Given code snippet:
    if (income <= 10000)
    tax = 0;
    tax = 12;
    Code Snippet using ternary operator:
    tax = income < = 10000? 0:12

  4. Marks [3]

    Write a statement for each of the following:

    1. Store a number 275 as a String
    2. Convert the string to a numeric value
    3. Add it to the existing total of 1000 to update the total.


    1. String number = (“275”);
    2. int n = Integer.ParseInt(275);
    3. 1000 + n;
  5. Marks [3]
    1. What is the role of the keyword void in declaring functions?
    2. If a function contains several return statements, how many of them will be executed?
    3. Which OOP Principle implements function overloading?


    1. A function which does not return any value, uses void as its return type. It is declared as a part of the function prototype only.
    2. The first return statement which the function encounters will be executed. Others will be ignored.
    3. Polymorphism
  6. Marks [6]

    What is the output of the following?

    1. System.out.println(“four:” +4 + 2);
      System.out.println(“four:” +(2+2));
    2. String S1 = “Hi”;
      String S2 = “Hi”;
      String S3 = “there”;
      String S4 = “HI” ;
      System.out.println(S1 + “equals” +S2 +”->” +S1.equals(S2));
      System.out.println(S1 + “equals” + S3 + “-»” + S1.equals (S3));
      System.out.println(S1+”equals” +S4 + “-»” +S1.equals(S4));
      System.out.println (S1 +”EqualIgnoreCase” +S4 +”->” + S1.EqualIgnoreCase(S4));


    1. Output:
      four: 42
      four: 4
    2. Output:
      HiequalsHi —»true
      Hiequalsthere —» false
      HiequalsHI —» false
      HiequalsIgnoreCaseHI —» true
  7. Marks [2]

    Evaluate the following expressions, if the values of the variables are a = 2, b = 3 and c = 9.

    1. a-(b++)*(–c)
    2. a*(++b)%c

    Ans. a = 2
    b = 3
    c = 9

    1. a-(b++)*(–c)
      = 2-(3++)*(–9)
      = -22
    2. a*(++b)%c
      = 2*(++3)%9
      = 2


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 salary described as below:
Data Members: Name, Address, Phone, Subject Specialization, Monthly Salary, Income Tax.
Member methods:

  1. To accept the details of a teacher including the monthly salary.
  2. To display the details of the teacher.
  3. To compute the annual Income Tax as 5% of the annual salary above Rs.1,75,000/-.

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

Answer 4

import java.io.*;

		public class Salary
 			private String name, address, subjectSpecialization;
 			private double pay, incomeTax;
 			private long phone;

 			public void TeacherDetails(String n, String addr, long ph, String subSpecl, double 																			salary)
				name = n;
				address = addr;
				phone = ph;
				subjectSpecialization = subSpecl;
				pay = salary;
			public void calcAnnuallcomeTax()
				double annualSalary = pay * 12;
				incomeTax = 0;
				if(annualSalary &gt; 175000)
				incomeTax = 0.05 * annualSalary;
			public void display()
				System.out.println(&quot;Teacher details:-&quot;);
				System.out.println(&quot;Name: &quot;+ name);
				System.out.println(&quot;Address: &quot;+ address);
				System.out.println(&quot;Phone: &quot;+ phone);
				System.out.println(&quot;Subject Specialization: &quot;+ subjectSpecialization);
				System.out.println(&quot;Salary: &quot;+ pay);
				System.out.println(&quot;Annual Income Tax: &quot;+ incomeTax);

			public static void main (String[] args) throws IOException
				BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
				Salary teacher = new Salary();
				System.out.println(&quot;Enter teacher details:-&quot;);
				System.out.print(&quot;Name: &quot;);
				String name = read.readLine();
				System.out.print(&quot;Address: &quot;);
				String address = read.readLine();
				System.out.print(&quot;Phone: &quot;);
				Long phone = Long.valueOf(read.readLine()).longValue();
				System.out.print(&quot;Subject Specialization: &quot;);
				String subjectSpecilization = read.readLine();
				System.out.print(&quot;Salary: &quot;);
				double salary = Double.valueOf(read.readLine()).doubleValue();
				teacher.TeacherDetails(name, address, phone, subjectSpecilization, salary);

Question 5

Marks [15]

Write a program to compute and display the sum of the following series:

Answer 5

import java.io.* ;

		public class SumOfSeries
			public static double Summation(int N)
				double s = 0;
				for(int i = 2; i &lt;= N; i++)
					s = s + i;
				return s;
			private static int Factorial(int N)
				int factN = 1;
				for(int i = 2; i &lt;= N; i++)
					factN = factN * i ;
				return factN;
			public static void main(String[]args) throws IOException
				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				System.out.print(&quot;Please enter value for N:&quot;);
				int n = Integer.parseInt(br.readLine( ));
				double sum = 0.0d;
				for(int i=1;i&lt;=n;i++)
				 sum = sum + Summation(i)/Factorial(i);

				System.out.println(&quot;Sum of the series for the &quot; +n +&quot; term is: &quot;+ sum);

Question 6

Marks [15]

Write a program to initialize the given data in an array and find the minimum and maximum values along with the sum of the given elements. Number: 2 5 4 1 3
Output: Minimum Value :1
Maximum Value : 5
Sum of the elements :

Answer 6

import java.io.*;
		public class ArrayUtil
			public static void main(String[] args) throws IOException
				int[] array = {2,5,4,1,3};
				int max = array[0];
				int min = array[0];
				int sum = array[0];
				for(int i = 1; i &lt;array.length; i++)
					sum += array[i];
					if(max &lt; array[i] )
						max = array[i];
					if(min &gt; array[i])
						min = array[i];
				System.out.println(&quot;Minimum value: &quot; +min);
				System.out.println(&quot;Maximum value: &quot; +max);
				System.out.println(&quot;Sum of the elements: &quot; +sum);

Question 7

Marks [15]

Write a program to enter a sentence from the keyboard and count the number of times a particular word occurs in it. Display the frequency of the search word.
Enter a sentence: the quick brown fox jumps over the lazy dog.
Enter a word to be searched: the
Search word occurs: 2 times

Answer 7

import java.io.*;

		public class WordCount
			public static void main(String[] args)throws IOException
				BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

				System.out.print(&quot;Enter any Sentence: &quot;);
				String text = input.readLine();

				int Count = 0;
				int index = -1;

				System.out.print(&quot;Enter the word to be searched: &quot;);
				String theStr = input.readLine();

				index = text.indexOf(theStr); // Return the 1st place of the word
					index += theStr.length();
					index = text.indexOf(theStr, index);

				// Print how many we have found the word
				System.out.println(Count + &quot; occurrences of the word '&quot; + theStr +
						&quot; was found in the text.\n&quot; );

Question 8

Marks [15]

Using a switch statement, write a menu driven program to convert a given temperature from Fahrenheit to Celsius and vice versa. For an incorrect choice, an appropriate error message should be displayed.
HINT: C = 5/9 x (F – 32) and F = 1.8 x C + 32

Answer 8

import java.io.*;
		class Temperature
			public static void main (String args[ ]) throws IOException
			String str, str1;
			int n = 0, k, choice;
			double C,F;
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

			System.out.println(&quot;1. Fahrenheit to Celsius&quot;);
			System.out.println(&quot;2. Celsius to Fahrenheit&quot;);
			System.out.print(&quot;Enter choice: &quot;);

				case 1:
					System.out.print(&quot;Enter the temperature in Fahrenheit to be converted: &quot;);
					C = (n-32) *5/9;
					System.out.println(&quot;Temperature in Celsius &quot; + C);
				case 2:
					System.out.print(&quot;Enter Temperature in Celsius to be converted: &quot;);
					F = (1.8*n) + 32;
					System.out.println(&quot;Temperature in Fahrenheit: &quot; + F);
					System.out.println(&quot;Incorrect Choice&quot;);

Question 9

Marks [15]

Write a program using a method Palin( ), to check whether a string is a palindrome or no palindrome is a string that reads the same from left to right and vice versa.

Answer 9

import java.io.*;

		public class palindrome
			public static void main(String args[]) throws IOException
				BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
				System.out.print(&quot;Enter a word to check whether it is a palindrome: &quot;);
				String str = br.readLine();
				StringBuffer t = new StringBuffer(str);
				StringBuffer strr = t.reverse();
				String h = new String(strr);
					System.out.print(&quot;The string is a palindrome&quot;);
					System.out.print(&quot;The string is not a palindrome&quot;);
One Comment

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.