ICSE Class 10 Computer Applications Question 1 of 30

Solved Sample Paper 3 — Question 1

Back to all questions
1
Question

Question 1(i)

What will be the output of the following code?

int size = 2;
if (size < 0)
    System.out.println("Small"); 
else if (size == 0)
    System.out.println("Medium");
else
    System.out.println("Large");
  1. Small
  2. Large
  3. Medium
  4. Runtime error
Answer

Large

Reason — Since size > 0, hence the conditions of if and else if are false. Thus, the else block will be executed and "Large" will be printed on the screen.