About Question enthuware.ocajp.i.v7.2.1264 :

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

Moderator: admin

Post Reply
admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1264 :

Post by admin »

You should know about the following methods, not because they are in List but because they are in ArrayList, which is on the exam:
add
addAll
remove
removeAll
sublist
retainAll
get
contains
clear
size
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

dxie1154
Posts: 9
Joined: Sat Jan 14, 2017 5:01 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1264 :

Post by dxie1154 »

I am a bit confused on how a, c, b is printed.
I originally thought a, c, b, c would be printed because the subList() method would return c, due to the fact that subList's starting value is inclusive, and the first value is c, so it should include the String c.
Why is a, c, b printed but not a, c, b, c?

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

Re: About Question enthuware.ocajp.i.v7.2.1264 :

Post by admin »

If fromIndex and toIndex are equal (as is the case in this question), subList returns empty list. This is as per https://docs.oracle.com/javase/8/docs/a ... t-int-int-

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Rick84
Posts: 12
Joined: Tue Mar 06, 2018 9:54 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1264 :

Post by Rick84 »

As background information; here are some notes by Edsger Dijkstra on why ranges should be expressed as lower <= x < upper

https://www.cs.utexas.edu/users/EWD/tra ... WD831.html

Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests