What is the most likely result?

Given:

What is the most likely result?

Given:

What is the most likely result?

A.
size: 4, elements: 11 22 33 44

B.
size: 5, elements: 11 22 33 44

C.
size: 4, elements: 11 22 33 44 77

D.
size: 5, elements: 11 22 33 44 77

E.
a ConcurrentModification Exception is thrown

Explanation:



Leave a Reply 8

Your email address will not be published. Required fields are marked *


Bahaa Khateib

Bahaa Khateib

After testing the same code in my machine i’ve got “D” please test

Bahaa Khateib

Bahaa Khateib

Answer should be E

Bahaa Khateib

Bahaa Khateib

Correct

l0c

l0c

Output:

Size: 5.
11 22 33 44

Answer should really be B.

test

test

As the name of the array implies, a new array is created on any changes (adding, removal, update) on the array.

As the iterator in the main thread is obtained before sleeping, changes to the list in the child-thread will not affect the list within that context.

However, if there are any access to the list after the loop that contains the sleep() in the main thread, any changes done to the list will be updated accordingly.

Klyaksa

Klyaksa

I tested and got result B.