Solved 2010 Question Paper ICSE Class 10 Computer Applications
Section A
Question 1
(a) Define the term Bytecode.
Answer
Java compiler converts Java source code into an intermediate binary code called Bytecode.
Bytecode can't be executed directly on the processor. It needs to be converted into Machine
Code first.
(b) What do you understand by type conversion? How is implicit conversion different from
explicit conversion?
Answer
The process of converting one predefined type into another is called type conversion. In an
implicit conversion, the result of a mixed mode expression is obtained in the higher most
data type of the variables without any intervention by the user. For example:
int a = 10;
float b = 25.5f, c;
c = a + b;
In case of explicit type conversion, the data gets converted to a type as specified by the
programmer. For example:
int a = 10;
double b = 25.5;
float c = (float)(a + b);
(c) Name two jump statements and their use.
Answer
break statement, it is used to jump out of a switch statement or a loop. continue statement,
it is used to skip the current iteration of the loop and start the next iteration.
(d) What is Exception? Name two exception handling blocks.
Answer
An exception is an event, which occurs during the execution of a program, that disrupts the
normal flow of the program's instructions. Two exception handling blocks are try and catch.
(e) Write two advantages of using functions in a program.
Answer
1. Methods help to manage the complexity of the program by dividing a bigger complex
task into smaller, easily understood tasks.
2. Methods help with code reusability.
Question 2
Page 1 of 5
(a) State the purpose and return data type of the following String functions:
1. indexOf()
2. compareTo()
Answer
1. indexOf() returns the index within the string of the first occurrence of the specified
character or -1 if the character is not present. Its return type is int.
2. compareTo() compares two strings lexicographically. Its return type is int.
(b) What is the result stored in x, after evaluating the following expression?
int x = 5;
x = x++ * 2 + 3 * --x;
Answer
x = x++ * 2 + 3 * --x
⇒x=5*2+3*5
⇒ x = 10 + 15
⇒ x = 25
(c) Differentiate between static and non-static data members.
Answer
Static Data Members Non-Static Data Members
They are declared using keyword They are declared without using keyword
'static'. 'static'.
All objects of a class share the same Each object of the class gets its own copy of
copy of Static data members. Non-Static data members.
They can be accessed using the class They can be accessed only through an object
name or object. of the class.
(d) Write the difference between length and length().
Answer
length length()
length is an attribute i.e. a data member of length() is a member method of
array. String class.
It gives the length of an array i.e. the number of It gives the number of characters
elements stored in an array. present in a string.
(e) Differentiate between private and protected visibility modifiers.
Answer
Page 2 of 5
Private members are only accessible inside the class in which they are defined and they
cannot be inherited by derived classes. Protected members are also only accessible inside
the class in which they are defined but they can be inherited by derived classes.
Question 3
(a) What do you understand by the term data abstraction? Explain with an example.
Answer
Data Abstraction refers to the act of representing essential features without including the
background details or explanations. A Switchboard is an example of Data Abstraction. It
hides all the details of the circuitry and current flow and provides a very simple way to
switch ON or OFF electrical appliances.
(b)(i) What will be the output of the following code?
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);
Answer
Output
m=6
n=14
Explanation
As there are no curly braces after the for loop so only the statement m++; is inside the loop.
Loop executes 4 times so m becomes 6. The next statement --n; is outside the loop so it is
executed only once and n becomes 14.
(b)(ii) What will be the output of the following code?
char x = 'A';
int m;
m = (x == 'a')? 'A' : 'a';
System.out.println("m = " + m);
Answer
Output
m = 97
Explanation
Page 3 of 5
The condition x == 'a' is false as X has the value of 'A'. So, the ternary operator returns 'a'
that is assigned to m. But m is an int variable not a char variable. So, through implicit
conversion Java converts 'a' to its numeric ASCII value 97 and that gets assigned to m.
(c) Analyze 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 = 1, i = 2;
while(++i < 6)
k *= i;
System.out.println(k);
Answer
Output
60
Explanation
This table shows the change in values of i and k as while loop iterates:
i k Remarks
2 1 Initial values
3 3 1st Iteration
4 12 2nd Iteration
5 60 3rd Iteration
6 60 Once i becomes 6, condition is false and loop stops iterating.
Notice that System.out.println(k); is not inside while loop. As there are no curly braces so
only the statement k *= i; is inside the loop. The statement System.out.println(k); is outside
the while loop, it is executed once and prints value of k which is 60 to the console.
(d) Give the prototype of a function check which receives a character ch and an integer n
and returns true or false.
Answer
boolean check(char ch, int n)
(e) State two features of a constructor.
Answer
1. A constructor has the same name as that of the class.
2. A constructor has no return type, not even void.
(f) 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.
Page 4 of 5
2. Check if the second character of a string str is in uppercase.
Answer
1. char ch = wd.charAt(wd.length() - 2);
2. boolean res = Character.isUpperCase(str.charAt(1));
(g) What will the following function return when executed?
1. Math.max(-17, -19)
2. Math.ceil(7.8)
Answer
1. -17
2. 8.0
(h)(i) Why is an object called an instance of a class?
Answer
A class can create objects of itself with different characteristics and common behaviour. So,
we can say that an Object represents a specific state of the class. For these reasons, an
Object is called an Instance of a Class.
(h)(ii) What is the use of the keyword import?
Answer
import keyword is used to import built-in and user-defined packages into our Java program.
Page 5 of 5