| Author |
Doubt: K&B Self Test (Resolved and in errata)
|
Gowher Naik
Ranch Hand
Joined: Feb 07, 2005
Posts: 643
|
|
hi on page no 74(K&B book) there is question as follows. A C and D is wrong.The book says B is correct but according to me the B is also wrong because there is no return type from speak method so this will not compile. plz help [ July 28, 2006: Message edited by: Barry Gaunt ]
|
 |
Shiaber Shaam
Ranch Hand
Joined: Jun 16, 2006
Posts: 252
|
|
|
It has return type of type "Bark" ... So it is not wrong .....
|
$Hi/\bEr
|
 |
Gowher Naik
Ranch Hand
Joined: Feb 07, 2005
Posts: 643
|
|
what i want to say is that method doesnot return anything
|
 |
Ramamoorthy Periasamy
Ranch Hand
Joined: Feb 06, 2006
Posts: 30
|
|
|
Well, The point here to understand is an abstract class can have non-abstract methods. NO need to check the code syntax unless its been asked explicitly
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
|
I think that this should be corrected because the question is asking for a compilable abstract class. If there is nothing returned in the body of the method it will not compile. So either return a Bark object or change return type to void. Hopefully Bert has already spotted this one before.
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
|
Yes, it is in the K&B 5.0 errata (see link at top of SCJP forum).
|
 |
d jones
Ranch Hand
Joined: Mar 13, 2006
Posts: 76
|
|
Could anyone please explain why Option A is not a compilable abstract class? Thanks, Dan
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
Originally posted by d jones: Could anyone please explain why Option A is not a compilable abstract class? Thanks, Dan
Change the return type to void and the compiler will scream the reason at you.
|
 |
 |
|
|
subject: Doubt: K&B Self Test (Resolved and in errata)
|
|
|