Which of the following can replace line 2 to make this code compile?
1: import java.util.*; 2: // INSERT CODE HERE 3: public class Main { 4: public void method(List<String> list) { 5: sort(list); 6: } 7: }
B.
To import static methods from we can do
import static java.util.Collections.*;
or
import static java.util.Collections.sort;
A is incorrect since you cannot do a static import on non-static members.
C is wrong since method parameters are not needed.
D, E, and F reverses the syntax of import static.