ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2020 ICSE Computer Science Paper



Share with a Friend

Solved 2020 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Short Questions/Answers - ICSE 2020 Computer Science

Question 1
a) Define encapsulation.
Encapsulation refers to wrapping up of the characteristics, state and behavior of an entity in a single unit.
b) Explain the purpose of using a ‘new’ keyword in a Java program.
The ‘new’ keyword instantiates a class by allocating memory for a new object.
c) What are literals?
Literals are data items that are fixed data values.
d) Mention the types of access specifiers.
public, private, protected and friendly.
e) What is constructor overloading?
The process of creating multiple constructors for a class that differ only on constructor signature is called constructor overloading.

Question 2
a) Differentiate between boxing and unboxing.
The process of converting a primitive data type value to its corresponding wrapper class is called boxing. For example, conversion from int to Integer.
The process of converting an object of wrapper class to its corresponding primitive data type value is called unboxing. For example, conversion from Integer to int.
b) Rewrite the following condition without using logical operators:

if(a > b || a > c)
    System.out.println(a);
if(a > b)
    System.out.println(a);
else if(a > c)
    System.out.println(a);

c) Rewrite the following loop using for loop:

while(true)
    System.out.print("*");
for(;;)
    System.out.print("*");

d) Write the prototype of a function search which takes two arguments (a string and a character) and returns an integer value.
int search(String s, char ch)
e) Differentiate between = and == operators.
The = operator is an assignment operator.
The == operator is a relational operator.

Question 3
a) State the number of bytes and bits occupied by a character array of 10 elements.
20 bytes or 160 bits.
b) Differentiate between binary search and linear search techniques.
Binary search can only work on sorted list of data.
Linear search can work on both sorted as well as unsorted list of data.
c) What is the output of the following:
String a = "Java is a programming language\ndeveloped by\t\'James Gosling\'";
System.out.println(a);

Java is a programming language
developed by    \'James Gosling\'

d) Differentiate between break and System.exit(0).
The break keyword is used to terminate a loop or a switch statement.
System.exit(0) is used to terminate a program.
e) Write a statement in Java for:


Math.sqrt((Math.pow(a + b), 3) / Math.abs(a - b))
f) What is the value of m after evaluating the following expression:
m -= 9 % ++n + ++n / 2; when int m = 10, n = 6;
m = m – (9 % ++n + ++n / 2)
= 10 – (9 % 7 + 8 / 2)
= 10 – (2 + 4)
= 10 – 6
= 4.
g) Predict the output of the following:
(i) Math.pow(25, 0.5) + Math.ceil(4.2)
= 5.0 + 5.0
= 10.0
(ii) Math.round(14.7) + Math.floor(7.9)
15.0 + 7.0
= 22.0
h) Give the output of the following Java statements:
(i) "TRANSPARENT".toLowerCase()
transparent
(ii) "TRANSPARENT".compareTo("TRANSITION")
7
i) Write a Java statement for each to perform the following tasks:
(i) Find and display the position of the last space in a string str.
System.out.println(str.lastIndexOf(\' \'));
(ii) Extract the second character of the string str.
char ch = str.charAt(1);
j) State the types of errors if any in the following statements:
(i) switch(n > 2)
Syntax error
(ii) System.out.println(100 / 0);
Run-time error