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:
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:
After testing the same code in my machine i’ve got “D” please test
Answer should be E
Correct
Output:
Size: 5.
11 22 33 44
Answer should really be B.
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.
Great
B
I tested and got result B.