This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt: K&B Self Test (Resolved and in errata)

 
Gowher Naik
Ranch Hand
Posts: 643
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has return type of type "Bark" ... So it is not wrong .....
 
Gowher Naik
Ranch Hand
Posts: 643
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what i want to say is that method doesnot return anything
 
Ramamoorthy Periasamy
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is in the K&B 5.0 errata (see link at top of SCJP forum).
 
d jones
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anyone please explain why Option A is not a compilable abstract class?


Thanks,
Dan
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic