ICSE Class 10 Computer Applications
Question 3 of 30
Solved Sample Paper 4 — Question 3
Back to all questions 3
Question Question 1(iii)
Predict the output of the following code snippet:
int a = 1;
int b = 2;
if (a == b)
System.out.println("Both values are equal");
else
System.out.println("Values are not equal");- Both values are equal
- Incorrect use of the == operator
- Values are not equal
- No output
Values are not equal
Reason — Since the values of a and b are not equal, the condition (a == b) is false. Thus, the else block is executed and "Values are not equal" is printed.