• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Examlab practice test 2 Q 27 - Boolean.parseBoolean - correction in explanation.

 
Sridhar Gudipalli
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source: Examlab practice test #2 Q#27.

What is the result of the following statement?



Ans: compilation fails.
Explanation: The method parseBoolean(String) is not available in java.lang.Boolean class.

However, here the parseBoolean("trUe") returns the boolean value "true" and then tries to call the getClass() method on the primitive which causes the below compilation error.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Cannot invoke getClass() on the primitive type boolean


Not sure if anyone already reported this or discussed here before.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic