Review Questions
15.16 Which statements about collections are true?
Select the two correct answers.
(a) Some operations on a collection may throw an UnsupportedOperationException
.
(b) Methods calling optional operations in a collection must either catch an UnsupportedOperationException
or declare it in their throws
clause.
(c) A List
can have duplicate elements.
(d) An ArrayList
can only accommodate a fixed number of elements.
(e) The Collection
interface contains a method named get
.
15.17 What will be the result of attempting to compile and run the following program?
import java.util.ArrayList;import java.util.Collection;import java.util.HashSet; ...
Get A Programmer’s Guide to Java™ SCJP Certification: A Comprehensive Primer, Third 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.