1.

When two threads access the same ArrayList object what is the outcome of the program?(a) Both are able to access the object(b) ConcurrentModificationException is thrown(c) One thread is able to access the object and second thread gets Null Pointer exception(d) One thread is able to access the object and second thread will wait till control is passed to the second oneThis question was addressed to me during a job interview.I need to ask this question from Data Structures-List in chapter java.util – The Collections Framework of Java

Answer»

Right choice is (B) ConcurrentModificationException is thrown

To explain I WOULD say: ArrayList is not SYNCHRONIZED. Vector is the synchronized DATA structure.



Discussion

No Comment Found

Related InterviewSolutions