ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2021 ICSE Computer Science Paper



Share with a Friend

Solved 2021 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Short Questions/Answers - ICSE 2021 Computer Science

Question 1

(a) Define Unicode.
Unicode is the character encoding system used in the Java language.

(b) Identify the following conversions as Autoboxing or Unboxing:
(i) Conversion of an Integer to an int.
Unboxing

(ii) Conversion of an int to an Integer.
Autoboxing

(c) Name the following literals:
(i) “ICSE”
String literal

(ii) ‘+’
Character literal

(iii) 254
Integer literal

(iv) false
Boolean literal

(d) Mention the two types of comments used in Java.
Single line comments
Multiline comments

(e) Rewrite the following using for loop:

int x = 10, y = 5;do{    x++;    y--;}while(x <= 15);System.out.println(x + y);int x = 10, y = 5;for(; x <= 15; x++)    y--;System.out.println(x + y);

Question 2

(a) Name the following:
(i) Parameters present in the method call statement.
Actual parameters

(ii) Smallest individual unit of a program.
Tokens

(b) State the purpose of the following methods:
(i) compareToIgnoreCase()
To compare two strings lexicographically while ignoring case differences.

(ii) trim()
To return a copy of the given string, with leading and trailing whitespaces omitted.

(c) What is a constructor?
A constructor is a special type of method that is used to create an object of a class. It doesn’t have any return type, not even void.

(d) Write a prototype of the method show() which receives a string and an integer as arguments and returns a character.
public char show(String s, int i)

(e) State the output of the following program segment:

int n = 47389, d;while(n > 10){    d = n % 10;    System.out.println(d);    n = n / 100;}System.out.println(n);

9
3
4

Question 3

(a) Differentiate between the methods indexOf() and lastIndexOf().
The indexOf() method returns the index of the first occurrence of a character in the given string. The lastIndexOf() method returns the index of the last occurrence of a character in the given string.

(b) What is the value of y after evaluating the expression given below?
y += ++y + –y + y–; when int y = 5;
y = y + (++y + –y + y–)
y = 5 + (6 + 5 + 5)
y = 5 + 16
y = 21

(c) Give the output of the following statements:

System.out.println("Good".concat("Day"));System.out.println("MERRYWORLD".substring(0, 5));System.out.println("My_dream".length());System.out.println("Memory".startsWith("Me"));

GoodDay
MERRY
8
true

(d) Write the output of the following statements:

System.out.println("result 1 = " + 6 + 2);System.out.println("result 2 = " + (6 + 2));

result 1 = 62
result 2 = 8

(e) Write the return data type of the following methods of Character class:

(i) isLetter()
boolean

(ii) toUpperCase()
char

(f) Predict the output of the following:

(i) Math.sqrt(196) + Math.pow(49, 0.5);
21.0

(ii) Math.floor(17.9) + Math.ceil(-17.5);
0.0

(g) What will be the output when the following code segment is executed?
int x = 5;
char ch = ‘C’;
int y = ch + 5;
System.out.println(y + ” ” + (char)y);

72 H

(h) What is the value of x and y in the following statements?
int a = 63, b = 36;

(i) boolean x = (a < b)? true : false;
x = false

(ii) int y = (a < b)? a : b;
y = 36

(i) What are library classes? Give an example.
The library classes are the in-built classes that contain useful methods to perform a certain task. Example: Integer class.

(j) Write a Java expression for the following:


(a * x * x + b * y) / (2 * a * b)