Multiple choice technology programming languages

public static void main(String[] args){ Integer i = new Integer(5); List myList; myList = new ArrayList(); myList.add(3); myList.add(5); myList.add(7); myList.remove(i); for(String s: myList) { System.out.println("List Value >> "+s); } } What is the output?

  1. 3,7

  2. 3,5,7

  3. index Outofbound exception

  4. Compilation fails

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The code fails to compile because Java generics cannot use primitive types. 'List' and 'ArrayList()' are invalid - you must use wrapper types like 'List' and 'ArrayList'. The compiler will reject this code at the declaration line, so no execution occurs.