Java - Exceptions - Interview Questions and Answers on ConcurrentModificationException

Q1. What is ConcurrentModificationException ?

Ans. This is the exception that is thrown when we try to modify the non concurrent collection class while iterating through it.

Q2.  What is CopyOnWriteArrayList ?

Ans. Its a type of ArrayList in which all Write operations , i.e add and set are performed by creating a new copy. This array never changes during the lifetime of the iterator, so it never throws ConcurrentModificationException

Q3.  What are the advantages and disadvantages of CopyOnWriteArrayList ?

Ans. This collections class has been implemented in such a manner that it can never throw ConcurrentModificationException. 

As it performs update and write operations by creating a new copy of ArrayList, It's slower compared to ArrayList.

Q4. Which interfaces are implemented by ConcurrentModificationException?


Q5. Which is the Parent Class of ConcurrentModificationException class?