Hi all.
Can someone shed some light on this question. It's from Bill Brogden's Exam Cram which is a really good book. I just don't quite follow the wording of this particular question & I would appreciate your help.
Here is the question:
You are writing a set of classes related to cooking and have your own exception heirarchy derived from java.lang.Exception as follows:
Exception
+- BadTasteException
+- BitterException
+- SourException
BadTasteException is defined as an abstract class.
You have a method eatMe that may throw a BitterException or a SourException. Which of the following method declarations will be acceptable to the compiler?
A) public void eat me(Ingredient [] list)throws BadTasteException
B) public void eat me(Ingredient [] list)throws BitterException,SourException
C) public void eat me(Ingredient [] list)may throw BadTasteException
D) public void eat me(Ingredient [] list)
I answered B & D. The correct answer from the book is A & B.
Generally speaking I would say I'm quite reasonable with exceptions, but I am stumped with this one. I think the biggest problem is I don't fully understand what the question is asking, I mean no offense to Bill as this has been a really helpful book which I highly recommend.
Can someone explain this a little more please?
Thanks, Dave.
