ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2017 ICSE Computer Science Paper



Share with a Friend

Solved 2017 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Short Questions/Answers - ICSE 2017 Computer Science

Question 1
(a) What is inheritance?
The process of deriving properties and behavior by a child class from a parent class is known as inheritance.

(b) Name the operators listed below:
(i) <
Less than operator (relational operator)
(ii) ++
Increment operator
(iii) &&
Logical AND operator
(iv) ?:
Conditional operator (Ternary operator)

(c) State the number of bytes occupied by char and int data types.
char occupies 2 bytes.
int occupies 4 bytes.

(d) Write one difference between / and % operator.
/ is used to find the quotient during integer division, whereas % is used to find the remainder.

(e) String x[] = {“SAMSUNG”, “NOKIA”, “SONY”, “MICROMAX”, “BLACKBERRY”};
Give the output of the following statements:

(i) System.out.println(x[1]);
NOKIA

(ii) System.out.println(x[3].length());
8

Question 2
(a) Name the following:

(i) A keyword used to call a package in the program.
import keyword

(ii) Any one reference data type.
String

 

(b) What are the two ways of invoking functions?
Call by value and call by reference

(c) State the data type and value of res after the following is executed:
char ch = ‘t’;
res = Character.toUpperCase(ch);

OUTPUT:

Data type = char
Value = ‘T’

(d) Give the output of the following program segment and also mention the number of times the loop is executed:
int a, b;
for(a = 6, b = 4; a <= 24; a = a + 6){
    if(a % b == 0)
        break;
}
System.out.println(a);

Output: 12
Number of times the loop executed: 2

(e) Write the output:
char ch = ‘F’;
int m = ch;
m = m + 5;
System.out.println(m + ” ” + ch);

OUTPUT:

75 F

Question 3
(a) Write a Java expression for the following:
ax
5 + bx3 + c

OUTPUT:

a * Math.pow(x, 5) + b * Math.pow(x, 3) + c

(b) What is the value of x1 if x = 5?
x1 = ++x – x++ + –x;

OUTPUT:

x1 = 6 – 6 + 6
x1 = 6

(c) Why is an object called an instance of a class?
An object is called an instance of a class because each object is unique and may have different state at any point of time.

(d) Convert the following do-while loop into for loop:
int i = 1;
int d = 5;
do{
    d = d * 2;
    System.out.println(d);
    i++;
}while(i <= 5);

OUTPUT:

int d = 5;
int i;
for(i = 1; i <= 5; i++){
    d = d * 2;
    System.out.println(d);
}

(e) Differentiate between constructor and function.
A constructor has no return type, whereas a function always has some return type.

(f) Write the output for the following:
String s = “Today is Test”;
System.out.println(s.indexOf(‘T’));
System.out.println(s.substring(0, 7) + ” ” + “Holiday”);

OUTPUT:

0
Today i Holiday

(g) What are the values stored in variables r1 and r2:

(i) double r1 = Math.abs(Math.min(-2.83, -5.83));

OUTPUT:

r1 = 5.83

(ii) double r2 = Math.sqrt(Math.floor(16.3));

OUTPUT:

r2 = 4.0

(h) Give the output of the following code:
String A = “26”, B = “100”;
String D = A + B + “200”;
int x = Integer.parseInt(A);
int y = Integer.parseInt(B);
int d = x + y;
System.out.println(“Result 1 = ” + D);
System.out.println(“Result 2 = ” + d);

OUTPUT:

Result 1 = 26100200
Result 2 = 126

(i) Analyze the given program segment and answer the following questions:
for(int i = 3; i <= 4; i++){
    for(int j = 2; j < i; j++){
        System.out.print(“”);
    }
    System.out.println(“WIN”);
}

(i) How many times does the inner loop execute?

OUTPUT:

3 times

(ii) Write the output of the program segment.

OUTPUT:

WIN
WIN

(j) What is the difference between the Scanner class functions next() and nextLine()?

Answer:

The next() method finds and returns the next complete token.
The nextLine() method advances the scanner past the current line and returns the input that was skipped.