Q4.You are writing a set of classes related to cooking and have created your own exception hierarchy derived from java.lang.Exception as follows Exception
+ x3 s" V6 j1 j& x4 W9 n" s +-- BadTasteException A7 t, C- n/ ?: E$ |, s% G9 [
+-- BitterException, W2 w& M& S q. |" A
+-- SourException
6 e+ Y% n6 V4 ^: n+ P Your base class, “BaseCook” has a method declared as follows int rateFlavor(Ingredient[] list) throws BadTasteException A class, “TexMexCook”, derived from BaseCook has a method which overrides BaseCook.rateFlavor(). Which of the following are legal declarations of the overriding method?
) q& |1 L; t8 u K8 O; h a. int rateFlavor(Ingredient[] list) throws BadTasteException; }$ k) V4 I3 f/ f O) W' z
b. int rateFlavor(Ingredient[] list) throws Exception7 U ]0 h. X" m
c. int rateFlavor(Ingredient[] list) throws BitterException, w: J5 J# {8 p4 a
d. int rateFlavor(Ingredient[] list)
7 o Q- Q' }# u, P Q5.You are working on an aquarium simulation class named Aquarius. You already have a method which adds a Fish object to the aquarium and returns the remaining fish capacity. This method has the following declaration." t8 }, ?6 _* X# D/ t
public int addFish( Fish f )+ ]+ f# u0 t1 m2 g% j$ q
Now you want to provide for adding a whole shoal of fish at once. The proposed method declaration is protected boolean addFish( Fish[] f ) The idea being that it will return true if there is more room in the tank or false if the tank now too full. Which of the following statements about this proposal are true?# O) [. j- [2 ~/ w$ e
a. This technique is called overloading.
3 N, D0 l5 |. s1 Y$ c! I b. This technique is called overriding.5 H( W1 h% b+ d# J0 ^( S. S- N+ s
c. The compiler will reject the new method because the return type is different.
: S0 l% t1 U8 _& ]5 l" V8 ^' R1 o: }
# X8 P$ T+ q5 |9 b# p d. The compiler will reject the new method because the access modifier is different. |