Hi,
this is question is from javabeat mock exam
The code given as
what is the answer of below and why?
Question 6 :
which statement is true?
a)The lines 2 and 3 will cause a compile error.
b)The line 4 will cause a compile error.
c)The line 5 will cause a compile error because a cast is missing.
d)The source code will be compiled with warning(s). During the runtime a ClassCastException will be thrown in the line 5.
e)The soure code will be compiled with warning(s). No exception will be thrown during the runtime.
Exam answer is:
Answer6 : d
c) No, a cast is not necessary. In a type safe code bO can contain only an orange. But our code is not type safe, because we use the generic class Basket<E> without specifying the concrete type for the type variable E. That is why we will be warned by the compiler.
can anyone justify the answer
[ August 16, 2007: Message edited by: madhu v pe ]
edited the too long lines, Bu.
[ August 16, 2007: Message edited by: Burkhard Hassel ]