tg-me.com/topJavaQuizExplain/229
Last Update:
Which of the following can replace line 2 to make the code compile?
❌ A. import static java.util.Collections;
✅ B. import static java.util.Collections.*;
❌ C. import static java.util.Collections.sort(ArrayList<String>);
❌ D. static import java.util.Collections;
❌ E. static import java.util.Collections.*;
❌ F. static import java.util.Collections.sort(ArrayList<String>);
Explanation:
The two valid ways to do this are import static java.util.Collections.*; and import static java.util.Collections.sort;. Option A is incorrect because you can do a static import only on static members. Classes such as Collections require a regular import. Option C is nonsense as method parameters have no business in an import. Options D, E, and F try to trick you into reversing the syntax of import static.
BY Explanations “Top Java Quiz Questions”
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Share with your friend now:
tg-me.com/topJavaQuizExplain/229