Given:
public class Main { public static void main(String... args) { boolean myBool = false; // line 1 int yourInt = 10; // line 2 float hisFloat = 19.54f; // line 3 System.out.println(hisFloat = yourInt); // line 4 System.out.println(yourInt > 10); // line 5 System.out.println(myBool = false); // line 6 }/*ww w. j a v a2 s . c o m*/ }
is the result?
a true /*ww w .ja v a 2 s . c o m*/ true false b 10.0 false false c false false false d Compilation error
b
The expression myBool
= false uses the assignment operator (=) and not a comparison operator (==).
This expression assigns the boolean literal false to myBool
; it doesn't compare false with myBool
.