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

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

Moderator: admin

Post Reply
vchhang
Posts: 36
Joined: Tue May 06, 2014 8:30 am
Contact:

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

Post by vchhang »

According to the explanation as I understand it, option#3 is correct but yet it is not. Please explain.

Except:
size() method of ArrayList returns the number of elements. Here, it returns 2. Since numbering in ArrayList starts with 0. al.get(2) will cause an IndexOutOfBoundsException to be thrown because only 0 and 1 are valid indexes for a list of size 2.

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

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

Post by admin »

It seems to be because of the same repaint problem that you reported earlier. Please see attached image.
Attachments
2.870.png
2.870.png (23.48 KiB) Viewed 2476 times
If you like our products and services, please help us by posting your review here.

JuergGogo
Posts: 28
Joined: Mon Sep 25, 2017 8:16 am
Contact:

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

Post by JuergGogo »

Code: Select all

ArrayList<String> al = new ArrayList<String>();
This ArrayList can be declared also like: ArrayList<String> al = new ArrayList<>();

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

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

Post by admin »

JuergGogo wrote:

Code: Select all

ArrayList<String> al = new ArrayList<String>();
This ArrayList can be declared also like: ArrayList<String> al = new ArrayList<>();
Yes, it can be.
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 41 guests