Two Laptop Bag*
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ExamLab Explanation...." Watch "ExamLab Explanation...." New topic
Author

ExamLab Explanation....

Michael Rootman
Greenhorn

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: 797

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.

Greetings.


SCJP 6
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ExamLab Explanation....