Predict the output of the following code snippet : int a = 1; int b = 2; if (a == b) System.out.println (“Both values are equal”)

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”);

(a) Both values are equal
(b) Incorrect use of the == operator
(c) Values are not equal
(d) No output

1 Comment

Add a Comment
  1. Suvankar Chakraborty

    Answer :

    The output of the given code snippet will be Values are not equal.

    Correct option is – (c) Values are not equal.

Leave a Reply

Your email address will not be published. Required fields are marked *