About Question enthuware.ocpjp.v11.2.3617 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
samba2
Posts: 6
Joined: Mon Sep 06, 2021 1:13 am
Contact:

About Question enthuware.ocpjp.v11.2.3617 :

Post by samba2 »

Code: Select all

List<Integer> aList = List.of(40, 30, 20);  //1
List<Integer> bList = List.copyOf(aList); //2
bList.sort((Integer::compare)); //3
System.out.println( bList ); //4
aList.sort((Integer::compare)); //5
System.out.println( aList ); //6
When working on that question I saw that both lists are read-only. However, line //5 is never reached as line //3 throws a RuntimeException which finishes execution (not handled at least in the visible code). Hence, I opted for "Only line //3 will cause an java.lang.UnsupportedOperationException to be thrown at runtime."

Am I mistaken here?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v11.2.3617 :

Post by admin »

Hi, yes, in such questions where the option statements point out individual lines, you can safely assume that the options are exactly about those lines if they are executed. As opposed to the problem statement that asks you about the output of executing a program.

This is specially true when the given code is not really a full executable program but just a code snippet.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests