Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ExamLab Explanation....

 
Michael Rootman
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 802
Hibernate Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Marco
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic