| 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: 14672
|
|
|
Check this.
|
[My Blog]
All roads lead to JavaRanch
|
 |
 |
|
|
subject: Examlab practice test 2 Q 27 - Boolean.parseBoolean - correction in explanation.
|
|
|