Given:
What happens when compiling and executing the given code?
A. Compilation fails on line 1
B. Compilation fails on line 2
C. ClassCastException is thrown on line 1
D. ClassCastException is thrown on line 2
E. No compile-time or runtime error occurs
Solution๐๐๐
Despite the fact that Number is a supertype of Long, the parameterized types List and ArrayList have no relationship.
The assignment on line 1 is therefore between incompatible types, which results in a compile-time error.
(๐๐ณ๐ณ๐ข๐บ๐๐ช๐ด๐ต<๐๐ฐ๐ฏ๐จ>() ๐ฅ๐ฐ๐ฆ๐ด ๐ฏ๐ฐ๐ต ๐ช๐ฏ๐ฉ๐ฆ๐ณ๐ช๐ต ๐ง๐ณ๐ฐ๐ฎ ๐๐ช๐ด๐ต<๐๐ถ๐ฎ๐ฃ๐ฆ๐ณ> ๐ธ๐ฉ๐ช๐ญ๐ฆ ๐๐ฐ๐ฏ๐จ ๐ช๐ฏ๐ฉ๐ฆ๐ณ๐ช๐ต๐ด ๐ง๐ณ๐ฐ๐ฎ ๐๐ถ๐ฎ๐ฃ๐ฆ๐ณ).
ยทโฑฏ sแด ษนวสsuษ สษวษนษนoษ วษฅ๊ :uoแดsnส ษuo๊