About Question enthuware.ocajp.i.v8.-2-.2015 :

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

Moderator: admin

Post Reply
BrentCoetzee
Posts: 5
Joined: Tue Apr 20, 2021 3:30 am
Contact:

About Question enthuware.ocajp.i.v8.-2-.2015 :

Post by BrentCoetzee »

The answer would give an java.lang.ArrayIndexOutOfBoundsException: 5

BrentCoetzee
Posts: 5
Joined: Tue Apr 20, 2021 3:30 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2015 :

Post by BrentCoetzee »

I believe the answer should be:

int[][] matrix = new int[5][4];
for(int i=0;i<5; i++) matrix[1]  = 1;

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

Re: About Question enthuware.ocajp.i.v8.2.2015 :

Post by admin »

Why do you believe so? Specifically, what makes you think that matrix[1] = 1; is valid?
Try compiling and running the code exactly as given in the question/option.
If you like our products and services, please help us by posting your review here.

BrentCoetzee
Posts: 5
Joined: Tue Apr 20, 2021 3:30 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2015 :

Post by BrentCoetzee »

Apologies, there should be before [1]

BrentCoetzee
Posts: 5
Joined: Tue Apr 20, 2021 3:30 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2015 :

Post by BrentCoetzee »

When posting a square bracket with letter i inside,it is removed as soon as i submit the post.

BrentCoetzee
Posts: 5
Joined: Tue Apr 20, 2021 3:30 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2015 :

Post by BrentCoetzee »

Apologies, I made a mistake the answer to the question is correct in your material. DUH moment for me.

Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests