Test Index
Collections and Generics
© examsnet.com
Question : 24 of 53
Marks:
+1,
-0
Place the correct description of the compiler output on the code fragments to be at lines 4 and 5. The same compiler output may be used more than once.
1. import java.util.*; 2. public class X { 3. public static void main(String[] args) { 4. /* insert code here*/ 5. /* insert code here*/ 6. } 7. public static void foo(List < Object > list) { 8. } } | Code | Compiler Output |
|---|---|
a. ArrayList < String > x1 = new ArrayList < String > (); foo(x1); | (i) Compilation succeeds |
b. ArrayList < Object > x2 = new ArrayList < String > (); foo(x2); | (ii) Compilation fails due to an error in the first statement |
c. ArrayList < Object > x3 = new ArrayList < Object > (); foo(x3); | (iii) Compilation of the first statement succeeds but compilation fails due to an error in the second statement |
d. ArrayList x4 = new ArrayList(); foo(x4); |
Go to Question: