What is the output?

Given the code fragment:

What is the output?
A. The compilation fails.
B. [-1, -2, -3]
C. [-3, -2, -1]
D. A runtime exception is thrown.

Download Printable PDF. VALID exam to help you PASS.

4 thoughts on “What is the output?

  1. D)

    Exception java.lang.UnsupportedOperationException
    | at ImmutableCollections.uoe (ImmutableCollections.java:72)
    | at ImmutableCollections$AbstractImmutableCollection.add (ImmutableCollections.java:76)

  2. It’s runtime exception because the list obtained with List.of() is immutable. trying to add elements is not possible.

    16

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.