Multiple choice technology programming languages

public static void main(String[] args) { Queue q = new LinkedList(); q.add("Veronica"); q.add("Wallace"); q.add("Duncan"); showAll(q); } public static void showAll(Queue q) { q.add(new Integer(42)); while (!q.isEmpty()) System.out.print(q.remove() + " "); }

  1. Veronica Wallace Duncan

  2. Veronica Wallace Duncan 42

  3. Duncan Wallace Veronica

  4. 42 Duncan Wallace Veronica

  5. Compilation fails

  6. An exception occurs at runtime.

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

The showAll method uses a raw Queue type (no generics), which bypasses compile-time type checking. This allows adding an Integer to what was originally a Queue. Elements are removed in FIFO order and concatenated with spaces.