| Author |
Bugtraking Devaka's Examlab
|
Anastasia Sirotenko
Ranch Hand
Joined: Jul 20, 2009
Posts: 64
|
|
Was working through 2nd exam round in Devaka's ExamLab (great software, i rely upon it to clear my future exam), found this bug in 27 question:
the answer is definitly should be something like " Boolean.parseBoolean(String) returns boolean value, not Boolean object, so you cannot call a getClass() method on boolean value"
|
[SCJP 6.0]
|
 |
Anastasia Sirotenko
Ranch Hand
Joined: Jul 20, 2009
Posts: 64
|
|
And one more may-be-bug (or i messed somewhere in my code and cannot find where)
The answer in ExamLab is:
But i ran the code:
ra1 = (Runnable[])ca; is defenetly compiles fine, it´s the same case as A[] aa2 = (A[])ra1; if i am not wrong.
PS My bad, i did not notice final modifier for class C, Devaka's code is good (tho evil!), surely now i will take more attention in future for such things, really great simulator 8)
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
Anastasia Sirotenko wrote:the answer is definitly should be something like " Boolean.parseBoolean(String) returns boolean value, not Boolean object, so you cannot call a getClass() method on boolean value"
Check the java.lang.Boolean class documentation. There is no parseBoolean method in it.
In your second code, you missed final before the class C...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Nitish Bangera
Ranch Hand
Joined: Jul 15, 2009
Posts: 536
|
|
|
Ankit parseBoolean is definitely there in the Boolean wrapper which gives out a boolean. Also it is case insensitive. The correct answer will be yes the primitive value cannot get a class. Well as for the second one, before casting think you apply a instanceof well instanceof is like on the right side there can be any interface but on the left of the instanceof there should be a non final class. Well same applies here. And if arrays are there then nonfinal class array instance of interface array >---->(Interface array)non final class array and not (Interface array)non final class. I guess this was there in the examlab.
|
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
|
 |
Anastasia Sirotenko
Ranch Hand
Joined: Jul 20, 2009
Posts: 64
|
|
Ankit Garg wrote:
Anastasia Sirotenko wrote:the answer is definitly should be something like " Boolean.parseBoolean(String) returns boolean value, not Boolean object, so you cannot call a getClass() method on boolean value"
Check the java.lang.Boolean class documentation. There is no parseBoolean method in it.
http://java.sun.com/javase/6/docs/api/java/lang/Boolean.html#parseBoolean(java.lang.String) here it is...
Ankit Garg wrote:your second code, you missed final before the class C...
Thank you very much! Here i get it 8)
It's not a Devaka's mistake, but mine here 8)
|
 |
Anastasia Sirotenko
Ranch Hand
Joined: Jul 20, 2009
Posts: 64
|
|
Nitish Bangera wrote:Well as for the second one, before casting think you apply a instanceof well instanceof is like on the right side there can be any interface but on the left of the instanceof there should be a non final class. Well same applies here. And if arrays are there then nonfinal class array instance of interface array >---->(Interface array)non final class array and not (Interface array)non final class. I guess this was there in the examlab.
Yes, i was mistaken with this final class, did not notice it, thank you 8)
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
Nitish Bangera wrote:Ankit parseBoolean is definitely there in the Boolean wrapper which gives out a boolean.
I messed up
|
 |
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
Nitish Bangera wrote:Ankit parseBoolean is definitely there in the Boolean wrapper which gives out a boolean.
So there is a bug in K&B book (rhyme )
Page 243 - parseBoolean is not marked.
|
SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
|
 |
Devaka Cooray
Saloon Keeper
Joined: Jul 29, 2008
Posts: 2691
|
|
Thanks for noticing. The first one is an error with the explanation, and it is already discovered before. - Will be fixed with the next update
Devaka.
|
Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
|
 |
Devaka Cooray
Saloon Keeper
Joined: Jul 29, 2008
Posts: 2691
|
|
Anastasia,
What is the screen resolution you are using there?
The appearance of the "Copy Program" button in your screenshot makes me confused.
|
 |
Nitish Bangera
Ranch Hand
Joined: Jul 15, 2009
Posts: 536
|
|
I hope you put the description for the formatter questions also. Little better than pointing to J2SE documention.
|
 |
Anastasia Sirotenko
Ranch Hand
Joined: Jul 20, 2009
Posts: 64
|
|
Devaka Cooray wrote:Anastasia,
What is the screen resolution you are using there?
The appearance of the "Copy Program" button in your screenshot makes me confused.
I am using 1280x1024 resolution. Realy did not pay attention how things look 8)
Great training software, Devaka, thank you for that!
|
 |
 |
|
|
subject: Bugtraking Devaka's Examlab
|
|
|