tg-me.com/topJavaQuizExplain/211
Last Update:
Which of the following pairs fill in the blanks to output 6?
❌ A. ArrayList and put(1, 6)
❌ B. ArrayList and replace(1, 6)
✅ C. ArrayList and set(1, 6)
❌ D. HashSet and put(1, 6)
❌ E. HashSet and replace(1, 6)
❌ F. HashSet and set(1, 6)
❌ G. The code does not compile with any of these options.
Explanation:
The put() method is used on a Map rather than a List or Set, making options A and D incorrect. The replace() method does not exist on either of these interfaces. Finally, the set method is valid on a List rather than a Set because a List has an index. Therefore, option C is correct.
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/211