OCA Java SE 8 Operators/Statements - OCA Mock Question Operator and Statement 15








Question

What is the output of the following code snippet?

     3: int x = 0; 
     4: String s = null; 
     5: if(x == s) 
     6:    System.out.println("Success"); 
     7: else 
     8:    System.out.println("Failure"); 


  1. Success
  2. Failure
  3. The code will not compile because of line 4.
  4. The code will not compile because of line 5.




Answer



D.

Note

The variable x is an int and s is String type.

The two data types are incomparable.