1. Which of these standard collection classes implement a dynamic array?
A) analyst
B) Linkedlist
c) ArrayList
d) AbstractSet
Answer: C
Explanation: The ArrayList class implements a dynamic array by expanding the AbstractList class.
2. Which of these classes can generate an array that can automatically increase and decrease in size?
A) aralist ()
B) DynamicList ()
C) LinkedList ()
D) maloclist ()
Answer: A
Explanation: None.
3. Which of these methods can be used to manually increase the capability of an ArrayList object?
A) capacity ()
B) Increased capacity ()
C) superiority ()
D) Assurance ()
Answer: D
Explanation: When we add an element, the ArrayList object's capacity is automatically increased, but we can manually increase it to the specified length x (x) using the function length;
4. Which method of the ArrayList class is used to obtain the current shape of an object?
a) size ()
B) length ()
C) index ()
D) Capacity ()
Answer: A
Explanation: None.
5. Which of these methods can be used to obtain a static array from an ArrayList object?
a) array ()
B) covertray ()
C) toArray ()
D) CoverAtray ()
Answer: C
Explanation: None.
6. Which method is used to reduce the capacity of an ArrayList object?
A) Trim ()
B) trimsize ()
C) trimToSize ()
D) trimto ()
Answer: D
Explanation: trimTosize () is used to reduce the size of an array array that locates an ArrayList object.
7. Implements a map collection interface?
A) true
B) false
Answer: B
Explanation: The collection interface provides add, remove, search, or iterate, while the map contains clear, get, put, remove, etc.
8. Which of the following maps does not implement the interface?
A) Hashup
B) Hashtable
C) EnumMap
d) vector
Answer: D
Explanation: Vector Abstract AbstractList that implements collections internally. Others come from implementing the map interface.
9. What is the basis of equality for IdentityHashMap?
A) context similarity
B) Name similarity
C) Hashcode equality
D) Length equality
Answer: A
Explanation: IdentityHashMap is rarely used because it violates the original contract () and hashcode () method of implementation.
10. What happens if we keep an important item in Hashup?
a) The new item replaces the old
b) new item has been discarded
c) The old object is removed from the map
D) It throws an exception because the key is already present in the map
Answer: A
Explanation: Hashpaps always have unique keys. If the same key is re-inserted, the new object replaces the previous object.
11. Hashmap is an ordered collection.
A) true
B) false
Answer: B
Explanation: Hashmap outputs the order of the key's hashcode. So this is uncontrolled, but will always have the same result for the same set of keys.
12. What happens if two threads use the same hashmap at the same time?
A) concurrent prohibition
B) NullPointerException
c) ClassNotFoundException
d) RuntimeException
Answer: A
Explanation: If two threads use the same hashmap at the same time, the code will throw a concurrentmodification exception.
13. How to synchronize Hashmap externally?
a) hashp.synchronize (hashp a);
B) HashPap A = new HashPap (); a.synchronize ();
c) Collections. synchronizedMap (new HashMap <string, string> ());
D) Collections.synchronize (new HashPap <String, String> ());
Answer: C
Explanation: Collection. SynchronizedMap () synchronizes the entire map. Concurrent marginalization provides thread protection without synchronizing the entire map.
14. How can we remove an object from ArrayList?
a) remove () method
b) Using Iterator
C) using the remove () method and Iterator
D) delete () method
Answer: C
Explanation: There are 2 ways to remove an object from ArrayList. We can use the overloaded method int index or object obj. We can also use an Iterator to delete an object.
15. How to remove duplicate from list?
A) HashSet <String> listTotSet = new HashSet <String> (duplist);
b) HashSet <string> listToSet = duplicateSt.ToSet ();
c) HashSet <string> listToSet = Collections.convertToSet (duplicatelist);
d) HashSet <string> listToSet = dupylist.getSet ();
Answer: A
Explanation: Duplicate elements are allowed in the list. The set contains unique objects.
16. How to sort ArrayList elements?
a) collection.sort (listObge);
B) collection.sort (listObge);
C) ListObz.Ort ();
D) Sorter.sortars (listOBJ);
Answer: B
Explanation: The collection provides a method for sorting the list. The order of sorting can be defined using a comparator.
17. What is the result of a program when two threads use the same ArrayList object?
A) Both are able to reach the object
B) ConcurrentModificationException is thrown
c) One thread is able to access the object and the other thread gets a Null Pointer exception
d) One thread is able to access the object and another thread will wait until control is passed to another.
Answer: B
Explanation: Array