in Education by
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 one This 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 Select the correct answer from above options Java questions and answers, Java questions pdf, Java question bank, Java questions and answers pdf, mcq on Java pdf, Java questions and solutions, Java mcq Test , Interview Java questions, Java Questions for Interview, Java MCQ (Multiple Choice Questions),Core Java Questions, Core Java MCQ,core java interview questions for experiencedcore java interview questions for 3 years experience,java programming questions,core java interview questions for freshers,java interview questions and answers for freshers, java programming questions and answers pdf, java interview questions for beginners

1 Answer

0 votes
by
 
Best answer
Right choice is (b) ConcurrentModificationException is thrown To explain I would say: ArrayList is not synchronized. Vector is the synchronized data structure.

Related questions

0 votes
    If two threads access the same hashmap at the same time, what would happen? (a) ConcurrentModificationException ... and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What happens if two threads simultaneously modify TreeSet? (a) ConcurrentModificationException is thrown (b) Both ... and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of these method can be used to increase the capacity of ArrayList object manually? (a) Capacity() ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of these method of ArrayList class is used to obtain present size of an object? (a) size() ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of these methods can be used to obtain a static array from an ArrayList object? (a) Array() ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    How can we remove an object from ArrayList? (a) remove() method (b) using Iterator (c) remove() ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    How to sort elements of ArrayList? (a) Collection.sort(listObj); (b) Collections.sort(listObj); (c ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What is the difference between length() and size() of ArrayList? (a) length() and size() return ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What is the worst case complexity of accessing an element in ArrayList? (a) O(n) (b) O(1) (c ... java programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What is the process of defining two or more methods within same class that have same name but different ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which of these can be used to differentiate two or more methods having the same name? (a) Parameters ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What is the process by which we can control what parts of a program can access the members of a ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which of these is used to access a member of class before object of that class is created? (a) ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which operator is used by Java run time implementations to free the memory of an object when it is no ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
...