Huawei
Company
Programming
Arrays
Select the correct option.
a)ArrayList is synchronized and Vector is unsynchronized.
b)ArrayList is unsynchronized and Vector is synchronized.
c)Both ArrayList and Vector are synchronized.
d)Both ArrayList and Vector are unsynchronized.
Read Solution (Total 4)
-
- b. Arraylist is unsynchronized and vector is synchronized
- 9 years agoHelpfull: Yes(6) No(0)
- ArrayList is unsynchronized and Vector is synchronized.
By default in JAVA, ArrayList is unsynchronized and hence AL are not Thread safe whereas, Vector is synchronized thereby allowing only one thread to act at a time hence making Vector, Thread safe.
In order to make ArrayList as Synchronized ArrayList, one can call synchronizedList() method.
This can be done as follows :
ArrayList al = new ArrayList();
List listObj = Collections.synchronizedList(al);
The above snippet makes the ArrayList object 'al' as synchronized List. - 8 years agoHelpfull: Yes(5) No(0)
- answer : Array list is unsychronized and vector is sychronized
- 8 years agoHelpfull: Yes(1) No(0)
- C. Both are synchronized
- 8 years agoHelpfull: Yes(0) No(6)
Huawei Other Question