ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2018 ICSE Computer Science Paper



Share with a Friend

Solved 2018 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Short Questions/Answers - ICSE 2018 Computer Science

Question 1

(a) Define abstraction.

Abstraction is the process of hiding unnecessary details and highlighting only essential details.

(b) Differentiate between searching and sorting.

Searching is the process of checking whether an element is present in a given list or not. Sorting is the process of arranging the elements in a list in a certain order.

(c) Write a difference between the functions isUpperCase() and toUpperCase().

The isUpperCase() function checks whether the given character is in uppercase or not. The toUpperCase() function converts a given character to uppercase.

(d) How are private members of a class different from public members?

The private members can only be accessed from within that class, whereas public members can be accessed from within that class as well as from the outside of that class.

(e) Classify the following as primitive or non-primitive data types.
(i) char

primitive data type

(ii) arrays

non-primitive data type

(iii) int

primitive data type

(iv) classes

non-primitive data type

Question 2

(a) (i) int res = ‘A’;
What is the value of res?

res = 65

(ii) Name the package that contains wrapper classes.
java.util package

(b) State the difference between while and do while loop.

The while loop is an entry-controlled loop, whereas the do-while loop is an exit-controlled loop.

(c) System.out.print(“BEST “);
System.out.println(“OF LUCK”);

Choose the correct option for the output of the above statements:

(i) BEST OF LUCK
(ii) BEST
OF LUCK

OUTPUT:

 (i) BEST OF LUCK

(d) Write the prototype of a function check which takes an integer as an argument and returns a character.

public static char check(int n)

(e) Write the return data type of the following function.
(i) endsWith()

OUTPUT:

boolean

(ii) log()

OUTPUT:

double

Question 3
(a) Write a Java expression for the following:

OUTPUT:

Math.sqrt(3 * x + x * x) / (a + b)

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

OUTPUT:

y = y + (++y + y– + –y)
y = 8 + (9 + 9 + 7)
y = 8 + 25
y = 33

(c) Give the output of the following:

(i) Math.floor(-4.7)

OUTPUT:

-5.0

(ii) Math.ceil(3.4) + Math.pow(2, 3)

OUTPUT:

12.0

(d) Write two characteristics of a constructor.

ANSWER:

A constructor doesn’t have any return type (not even void).
Constructors are invoked during object creation.

(e) Write the output for the following:
System.out.println(“Incredible” + “\n” + “world”);

OUTPUT:

Incredible
world

(f) Convert the following if else if construct into switch case:

if(var == 1)
   System.out.println("good");
else if(var == 2)
          System.out.println("better");
       else if(var == 3)
                System.out.println("best");
       else
                System.out.println("invalid");

OUTPUT:

switch(var){
  case 1:
      System.out.println("good");
      break;
  case 2:
     System.out.println("better");
     break;
  case 3:
     System.out.println("best");
     break;
  default:
    System.out.println("invalid");
}

(g) Give the output of the following string functions:

(i) “ACHIEVEMENT”.replace(‘E’, ‘A’)

OUTPUT:

ACHIAVAMANT

(ii) “DEDICATE”.compareTo(“DEVOTEE”)

OUTPUT:

-17

(h) Consider the following String array and give the output:
String arr[] = {“DELHI”, “CHENNAI”, “MUMBAI”, “LUCKNOW”, “JAIPUR”};
System.out.println(arr[0].length() > arr[3].length());
System.out.print(arr[4].substring(0, 3));

OUTPUT:

true
JAI

(i) Rewrite the following using ternary operator:
if(bill > 10000)
discount = bill * 10.0 / 100;
else
discount = bill * 5.0 / 100;

OUTPUT:

discount = (bill > 10000)? bill * 10.0 / 100 : bill * 5.0 / 100;

(j) Give the output of the following program segment and also mention how many times the loop is executed:
int i;
for(i = 5; i > 10; i++)
    System.out.println(i);
System.out.println(i * 4);

OUTPUT: 20