• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

ExamLab Explanation....

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 814
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic