How many lines does the following code output?
import java.util.*; public class Main { public static void main(String[] args) { List<String> v = Arrays.asList("OCA", "OCP"); for (String e1 : v) for (String e2 : v) System.out.println(e1 + " " + e2); } }
B.
Looping through the same list multiple times is allowed.
The outer loop executes twice.
The inner loop executes twice for each of those iterations of the outer loop.
Therefore, the inner loop executes four times, and Option B is correct.