Given the code fragment: Which one is valid as a replacement for foo?
A.
b1.compareTo(b2)
B.
i = 1
C.
i == 2? -1 : 0
D.
“foo”.equals(“bar”)
Explanation:
Given the code fragment: Which one is valid as a replacement for foo?
A.
b1.compareTo(b2)
B.
i = 1
C.
i == 2? -1 : 0
D.
“foo”.equals(“bar”)
Explanation:
D because it produces a boolean value and a while loop accepts arguments of type boolean or Boolean.
http://www.aiotestking.com/oracle/which-one-is-valid-as-a-replacement-for-foo-2/
Answer: D