What will be the output of the following code segment written in Java.
Answer: C
Explanation:
In segment 'if (valid)' valid must be of type Boolean, but it is a string.
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:
Post a Comment