ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2010 ICSE Computer Science Paper



Share with a Friend

Solved 2010 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Short Questions/Answers - ICSE 2010 Computer Science

Question 1

(a) Define the term Bytecode.
Bytecode is a machine instruction for a Java processor chip called Java Virtual Machine (JVM).

(b) What do you understand by type conversion? How is implicit conversion different from explicit conversion?
The process of converting one predefined type into another is called type conversion.
Implicit conversion takes place automatically.
Explicit conversion is done forcefully.

(c) Name two jump statements and their use.
The break statement is used to exit from a loop or a switch case.
The continue statement is used to move to the next iteration of the loop.

(d) What is Exception? Name two exception handling blocks.
An exception is an abnormal condition that arises in a code sequence at run-time.
Two exception handling blocks are try and catch.

(e) Write two advantages of using functions in a program.
Functions lets us reuse code.
Functions reduce code complexity.

Question 2

(a) State the purpose and return data type of the following String functions:
(i) indexOf()

Purpose: to find the index of the first occurrence of a given character or string.
Return data type: int
(ii) compareTo()
Purpose: to compare the contents of two strings.
Return data type: int

(b) What is the result stored in x, after evaluating the following expression?
int x = 5;
x = x++ * 2 + 3 * --x;

= 5 * 2 + 3 * 5
= 10 + 15
= 25.

(c) Differentiate between static and non-static data members.
The static data member is common for all the objects for a given class.
The non-static data members are created separately for each object for a given class.

(d) Write the difference between length and length().
The length is used to find the size of an array.
The length() is used to find the length of a string object.

(e) Differentiate between private and protected visibility modifiers.
The private data members can only be accessed from within the class.
The protected data members can be accessed from within the class as well as from the sub-classes.

Question 3

(a) What do you understand by the term data abstraction? Explain with an example.
The act of representing essential features without including background details is known as data abstraction.
Example:
class Rectangle{
    private double length;
    private double width;
    public double area(){
        return length * width;
    }
}

In the above code, the inner details of the class are hidden through encapsulation, which leads to data abstraction.

(b) What will be the output of the following code?
(i) 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);

m = 3
n = 14
(ii) char x = \'A\';
int m;
m = (x == \'a\')? \'A\' : \'a\';
System.out.println("m = " + m);

m = 97

(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);

The loop executes 3 times.
OUTPUT: 60

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

(e) State two features of a constructor.
Constructors have the same name as their class name.
Constructors don’t have any return type (not even void).

(f) Write a statement each to perform the following task on a string:
(i) Extract the second-last character of a word stored in the variable wd.

wd.charAt(wd.length() - 2)
(ii) Check if the second character of a string str is in uppercase.
Character.isUpperCase(str.charAt(1))

(g) What will the following function return when executed?
(i)
Math.max(-17, -19)
-17
(ii) Math.ceil(7.8)
8.0

(h) (i) Why is an object called an instance of a class?
An object is called an instance of a class because an object materialize the abstraction represented by the class. Every object will have its own state, even though they have same structure and behavior.
(ii) What is the use of the keyword import?
The import keyword is used to include packages and interfaces into the current file.