Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ExamLab 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 Explanation...." Watch "ExamLab Explanation...." New topic

ExamLab Explanation....

Michael Rootman

Joined: Apr 15, 2009
Posts: 19
Hi All,

I am doubt about explanation for following question(Q 27 of Practice exam 2) :

What is the result of:

Correct answer is "Compilation Error", but explanation is "The method parseBoolean(String) is not available in java.lang.Boolean class"

I do have parseBoolean in Boolean class and I think all wrapper classes have .parseXXX. To my opinion the answer "Compilation Error" is correct because parseBoolean returns primitive boolean and getClass method cannot be applied on primitive.

Am I wrong? Please Explain.
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 802

Hello Michael Rootman,
parseBoolean is available and note the name of getClass it is a method it should be getClass().
parseBoolean return primitive so boolean cannot be dereferenced.

SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
David Marco
Ranch Hand

Joined: Feb 23, 2009
Posts: 44
A little comment: all the wrapper classes do not have a parseXxx() method (Character is the rule exception). So, the seven classes with their own parseXxx method are:

- The six numeric classes (Byte, Short, Integer, Long, Float, Double).
- The Boolean class.


I agree. Here's the link:
subject: ExamLab Explanation....
It's not a secret anymore!