Review Questions

11.4 Which statements are true about collections?

Select the two correct answers.

  1. Some operations on a collection may throw an UnsupportedOperationException.

  2. Methods calling optional operations in a collection must either catch an UnsupportedOperationException or declare it in their throws clause.

  3. A List can have duplicate elements.

  4. An ArrayList can only accommodate a fixed number of elements.

  5. The Collection interface contains a method named get.

11.5 What will be the result of attempting to compile and run the following program?
 import java.util.*; public class Sets { public static void main(String[] args) { HashSet set1 = new HashSet(); ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.