OBJECTIVE: Write Generic Methods (Objective 6.4)
class Food { }
class
Fruit extends Food { }
class Apple extends Fruit { }
// insert code here
public static void main(
String[] munch) {
Pie<Fruit> p = new Pie<Fruit>();
}
}
Which inserted at // insert code here, will compile? (Choose all that apply.)
A. class Pie<T extends Food>{
B. class Pie<T extends Fruit>{
C. class Pie<T extends Apple>{
D. class Pie<T extends Pie>{
E. class Pie<T super Apple>{
F. class Pie<T>{
-------------------
correct answer is:A, B, and F are correct. C and D are incorrect because Fruit is not "in bounds" as a type of Apple or Pie when you try to instantiate a new Pie. E is incorrect syntax.
---------------------------
my answer is: A,E,F
Why E is incorrect?
Thanks
[ August 29, 2008: Message edited by: Samson Harry ]