Java OCA OCP Practice Question 1566

Question

Which of the following will not give any error at compile time and run time?

Select 4 options

  • A. if (8 == 81) {}
  • B. if (x = 3) {} // assume that x is an int
  • C. if (true) {}
  • D. if (bool = false) {} //assume that bool is declared as a boolean
  • E. if (x == 10 ? true:false) { } // assume that x is an int


Correct Options are  : A C D E

Note

All an if (...) needs is a boolean.

x = 3 is not valid because the return value of this expression is 3 which is not a boolean.




PreviousNext

Related