generic is my weak point and it is the area that I will lose points in OCP exam. I have problem understanding K&B Practice Exam 4 (34). Would someone please explain it for me? Thanks.
34)
2. public class Organic<E> {
3. void react(E e) {}
4. static void main(
String[] args) {
5. //Organic<? extends Organic> compound = new Aliphatic<Organic>();
6. //Organic<? super Aliphatic> compound = new Aliphatic<Organic>();
7. compound.react(new Organic());
8. compound.react(new Aliphatic));
9. compound.react(new Hexane());
10. }}
11. class Aliphatic<F> extends Organic<F> {}
12. class Hexane<G> extends Aliphatic<G> {}
Which, taken independently, are true?
A. If line 5 is uncommented, compilation fails due to an error at line 7.
B. If line 5 is uncommented, compilation fails due to an error at line 8.
C. If line 5 is uncommented, compilation fails due to an error at line 9.
D. If line 6 is uncommented, compilation fails due to an error at line 7.
E. If line 6 is uncommented, compilation fails due to an error at line 8.
F. If line 6 is uncommented, compilation fails due to an error at line 9.
The answers are A,B,C, and D. As for why, I am totally lost in understanding the explanation.