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

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

Moderator: admin

jswmth
Posts: 2
Joined: Wed Feb 08, 2017 11:41 am
Contact:

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

Post by jswmth »

I understand the nuances of the discussion above but I too also think that the option "It throws StringIndexOutOfBoundsException if passed a value higher than or equal to the length of the string (or less than 0)." is true, because that is exactly what charAt() currently does.

Just because the exception thrown by charAt() could be changed in future doesn't mean that the option is wrong at the moment.

Perhaps the option should be reworded to:
"It throws StringIndexOutOfBoundsException if passed a value higher than or equal to the length of the string (or less than 0) and your code would be safe to anticipate this exception."

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

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

Post by admin »

That is your call and it is fine. :thumbup:
If you like our products and services, please help us by posting your review here.

stevemak
Posts: 1
Joined: Sat Apr 03, 2021 5:07 am
Contact:

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

Post by stevemak »

I find this question very unfair as it has more than 2 correct answers. The answer:

It throws StringIndexOutOfBoundsException if passed a value higher than or equal to the length of the string (or less than 0)

Is very valid as this is what get's returned in practice, same reason why Java certification requires experience before taking any certification not just theories. If someone is able to show me code that returns a different exception other than StringIndexOutOfBoundsException if you pass a value higher than or equal to length of string then I might change my mind. If there is no such evidence I say what the method does in practice takes precedence over any documentation or explanation we might give. When I'm in the field what exception do I see not what it might be? I hope the actual exam does not have such answers for this question as it's just unfair !!

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 38 guests