Wednesday, June 25, 2014

OCJP Question #24

1:19 PM

What will be the output of the following code segment written in Java.

Answer: C


In segment 'if (valid)' valid must be of type Boolean, but it is a string.

This makes the compilation fail.

Detailed Explanation:

If is a conditional statement it requires Boolean value to be passed , since valid is a type of String not of Boolean, so it will make compilation of the program fail. 

This holds true for while loop also.

More Questions on OCJP : Click here 

More Questions on Hibernate : Click here 


Post a Comment


© 2014 DieHardTechy . All rights resevered. Designed by Diehardtechy