Computer Applications
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
Java Conditional Stmts
11 Likes
Answer
Values are not equal
Answered By
2 Likes
Related Questions
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.printIn("Large");
What will be the output of the following code?
int fruit = 3; switch (fruit + 1) { case 1: System.out.println("Banana"); break ; case 2: System.out.println("Apple"); break ; case 3: System.out.println("Orange"); break ; default : System.out.println("Fruitless"); }
Consider the following code snippet:
if ( c > d) x = c; else x = d;
Choose the correct option if the code mentioned above is rewritten using the ternary operator:
if ((a > b) && (a > c)), then which of the following statements is true?