Tech Me More

To quench our thirst of sharing knowledge about our day to day experience & solution to techincal problems we face in our projects.

Advertise with us !
Send us an email at

Wednesday, June 25, 2014

OCJP Question #24

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 

No comments: