"Do not wait for leaders; do it alone, person to person."
- Mother Teresa
3.
Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
[A].
java.util.HashSet
[B].
java.util.LinkedHashSet
[C].
java.util.List
[D].
java.util.ArrayList
Answer: Option A
Explanation:
All of the collection classes allow you to grow or shrink the size of your collection. ArrayList provides an index to its elements. The newer collection classes tend not to have synchronized methods. Vector is an older implementation of ArrayList functionality and has synchronized methods; it is slower than ArrayList.
Jagan M Reddy said:
(Mon, Aug 29, 2011 12:16:36 PM)
What about java.util.list, I think its correct but I think its interface. I have doubt over here please can u solve it for me ?
Omprakash said:
(Fri, Jan 25, 2013 02:22:52 PM)
The current code will not compile due to the error introduced due to incorrect paranthesis.
The correct code would be,
java.io.PrintWriter out = new java.io.PrintWriter(new java.io.OutputStreamWriter(System.out), true);
PrintWriter accepts OutputStream and boolean as its arguments in one its constructor. The above code will ensure that the PrintWriter obj acts as System.out