About Question enthuware.ocajp.i.v7.2.1264 :
Moderator: admin
About Question enthuware.ocajp.i.v7.2.1264 :
Are LinkedList on the OCAJP exam?
The_Nick
The_Nick
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
The exam objectives specifically mention only ArrayList. However, some students have reported LinkedList used in some cases without affecting the answers. So you need not study much about it except that it exists.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 3
- Joined: Sun Jun 23, 2013 10:48 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
sublist(1 , 1) should return "c" in sublist , as s1 is now = "a","c","b".
So, there are elements at index 1 i.e. "c"
So, there are elements at index 1 i.e. "c"
-
- Posts: 22
- Joined: Wed Aug 21, 2013 12:29 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
Hi all,
if subList(int start, int end) has the first parameter, start, as inclusive and the second parameter, end, as exclusive why doesn't this throw an IndexOutOfBoundsException?
Since 1 is actually position 2, because arrays are zero based, and 1 exclusive is position 0 shouldn't this throw an exception or something since the end index is before the beginning?
Regards,
Javanaut
if subList(int start, int end) has the first parameter, start, as inclusive and the second parameter, end, as exclusive why doesn't this throw an IndexOutOfBoundsException?
Since 1 is actually position 2, because arrays are zero based, and 1 exclusive is position 0 shouldn't this throw an exception or something since the end index is before the beginning?
Regards,
Javanaut
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
What call exactly do you think should throw IndexOutOfBoundsException?
Regardless, this depends on how the method is coded. You can check out the source code for sublist method and see how exactly it treats the end index and know how it avoids the exception.
HTH,
Paul.
Regardless, this depends on how the method is coded. You can check out the source code for sublist method and see how exactly it treats the end index and know how it avoids the exception.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 22
- Joined: Wed Aug 21, 2013 12:29 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
Paul,
I will have to dig into the source code for this method and see what is preventing the runtime exception. Thank-you for the reply.
Thank-you for the reply,
Kyle
I will have to dig into the source code for this method and see what is preventing the runtime exception. Thank-you for the reply.
Thank-you for the reply,
Kyle
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
BTW, that is not required for the exam though
If you like our products and services, please help us by posting your review here.
-
- Posts: 7
- Joined: Mon Jan 27, 2014 6:25 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
the same logic with String.substring()
and StringBuilder.substring()
?
and StringBuilder.substring()
?
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
Kindly write complete question. I have no idea which logic are you talking about.
-Paul.
-Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 63
- Joined: Fri Oct 31, 2014 6:31 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
In order to answer this question, we should know the method subList(). I thought the answer may be a c b c. Thinking subList() will return c. How many such methods should we know from List interface for this exam? I have never come across list to be a part of exam objective, in any of the books!!!!
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
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.
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.
-
- Posts: 9
- Joined: Sat Jan 14, 2017 5:01 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
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?
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?
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 12
- Joined: Tue Mar 06, 2018 9:54 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
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
https://www.cs.utexas.edu/users/EWD/tra ... WD831.html
Who is online
Users browsing this forum: No registered users and 54 guests