Multiple choice technology

Given: 1. import java.util.*; 2. public class Old { 3. public static Object get0(List list) { 4. return list.get(0); 5. } 6. } Which three will compile successfully? (Choose three.)

  1. Object o = Old.get0(new LinkedList());

  2. Object o = Old.get0(new LinkedList<?>());

  3. String s = Old.get0(new LinkedList<String>());

  4. Object o = Old.get0(new LinkedList<Object>());

  5. String s = (String)Old.get0(new LinkedList<String>());

Reveal answer Fill a bubble to check yourself
A,D,E Correct answer
Explanation

Option A compiles because LinkedList is raw and get0() returns Object. Option D compiles as LinkedList matches Object return. Option E compiles with the explicit cast to String. Option B fails because LinkedList> is wildcard-typed and get0() expects raw List. Option C fails because String != Object return type without casting.