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 Java bytecode.
Java bytecode is an intermediate code that gets generated when the Java source code is compiled. It is platform independent.

(b) Write a difference between class and an object.
A class is a collection of related objects. It acts as a data type for an object.
An object is an instance of a class.

(c) Name the following:
(i) The keyword which converts variable into constant.
The final keyword
(ii) The method which terminates the entire program from any stage.
System.exit(0);

(d) Which of the following are primitive data types?
(i) double

Primitive data type
(ii) String
Non-primitive data type
(iii) char
Primitive data type
(iv) Integer
Non-primitive data type

(e) What is an operator? Name any two types of operators in Java.

An operator is a symbol that when applied with operand(s) gives some meaningful result.
Two categories of operators: Arithmetic operators, Relational operators.

Question 2
(a) What is autoboxing in Java? Give an example.

Autoboxing is process of automatic conversion between the primitive types and their corresponding object wrapper classes.
Example:
int a = 5;
Integer i = a; //autoboxing

(b) State the difference between length and length() in Java.

The length property is used in arrays to find the size of arrays. The length() method is used with string objects to find the total number of characters present in the string.

(c) What is constructor overloading?

The process of creating more than one constructor for a class that differ in their signatures is known as constructor overloading.

(d) What is the use of import statement in Java?

The import statement is used to include packages into our program.

(e) What is an infinite loop? Give an example.

A loop that doesn’t terminate is an infinite loop.
Example:
while(true)
System.out.println(“Hello”);

Question 3

(a) Write a Java expression for the following:

Math.sqrt(b * b – 4 * a * c)

(b) Evaluate the following if the value of x = 7, y = 5
x += x++ + x + ++y;

x = x + (x++ + x + ++y)
x = 7 + (7 + 8 + 6)
x = 7 + 21
x = 28

(c) Write the output for the following:
String s1 = “Life is Beautiful”;
System.out.println(s1.endsWith(“L”));

false

(d) Write the output of the following statement:
System.out.println(“A picture is worth \t \”A thousand words.\””);

A picture is worth “A thousand words.”

(e) Give the output of the following program segment and mention how many times the loop will execute:

int k;
for(k = 5; k <= 20; k += 7)
     if(k % 6 == 0)
         continue;
 System.out.println(k);

Output: 26
The loop executes 3 times.

(f) What is the data type returned by the following library methods?
(i) isWhitespace() boolean data type
(ii) compareToIgnoreCase() int data type

(g) Rewrite the following program segment using logical operators:
if(x > 5)
   if(x > y)
      System.out.println(x + y);

if(x > 5 && x > y)
   System.out.println(x + y);

(h) Convert the following if else if construct into switch case:
if(ch == ‘c’ || ch == ‘C”)
     System.out.print(“COMPUTER”);
else if(ch == ‘h’ || ch == ‘H’)
            System.out.print(“HINDI”);
       else
           System.out.print(“PHYSICAL EDUCATION”);

switch(ch){
      case ‘c’:
      case ‘C’:
             System.out.print(“COMPUTER”);
             break;
      case ‘h’:
      case ‘H’:
             System.out.print(“HINDI”);
             break;
      default:
            System.out.print(“PHYSICAL EDUCATION”);

(i) Give the output of the following:

(i) Math.pow(36, 0.5) + Math.cbrt(125)
11.0
(ii) Math.ceil(4.2) + Math.floor(7.9)
12.0

(j) Rewrite the following using ternary operator:
if(n1 > n2)
    r = true;
else
   r = false;

r = (n1 > n2)? true : false;