File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Examlab practice test 2 Q 27 - Boolean.parseBoolean - correction in explanation. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Examlab practice test 2 Q 27 - Boolean.parseBoolean - correction in explanation." Watch "Examlab practice test 2 Q 27 - Boolean.parseBoolean - correction in explanation." New topic
Author

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

Sridhar Gudipalli
Ranch Hand

Joined: Nov 02, 2005
Posts: 120
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.


Sridhar Gudipalli|SCJP 6.0
SCWCD objectives
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Check this.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Examlab practice test 2 Q 27 - Boolean.parseBoolean - correction in explanation.