JAVA
2.7K subscribers
73 photos
111 files
76 links
Download Telegram
What implementation of Iterator can traverse a collection in both directions?
Anonymous Quiz
24%
Iterator
45%
ListIterator
14%
SetIterator
17%
MapIterator
The Comparable interface contains which called?
Anonymous Quiz
40%
toCompare
9%
compare
43%
compareTo
9%
compareWith
Which is faster and uses less memory?
Anonymous Quiz
22%
ListEnumeration
31%
Iterator
42%
Enumeration
6%
ListIterator
What Iterator can throw a ConcurrentModificationException?
Anonymous Quiz
25%
Fail-fast Iterators
18%
b.Fail-safe Iterators
54%
All of these
4%
None of these
What is the default number of Partitions/segments in Concurrent Hash Map?
Anonymous Quiz
20%
12
30%
32
17%
4
33%
16
Which is best suited to a multi-threaded environment?
Anonymous Quiz
12%
WeakHashMap
32%
Hashtable
29%
HashMap
26%
ConcurrentHashMap
The default capacity of a Vector is:
Anonymous Quiz
29%
10
41%
12
18%
8
12%
16
Which does NOT implement the Collection interface?
Anonymous Quiz
8%
a.List
46%
b.Map
8%
c.Set
38%
None of these
The default capacity of a ArrayList is:
Anonymous Quiz
12%
12
26%
16
21%
1
40%
10
Which provides better performance for the insertion and removal from the middle of the list?
Anonymous Quiz
6%
Vector
31%
ArrayList
40%
LinkedList
23%
All of these
import java.util.Arrays;
import java.util.Comparator;
class Sort implements Comparator<Integer>{
public int compare(Integer o1,Integer o2){
return o2.compareTo(o1);
}
}
public class Program
{
public static void main(String[] args) {
Integer intArray[]={2,3,1};
Arrays.sort(intArray,new Sort());
for(int i: intArray ){
System.out.print(i+" ");
}
}
}
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
public class Program
{
public static void main(String[] args) {
Set set=new TreeSet();
set.add(1);
set.add("2");
set.add(3);
Iterator iterator=set.iterator();

while(iterator.hasNext()){
System.out.print(iterator.next()+" ");
}
}
}
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Program
{
public static void main(String[] args) {
List<String> arrayList=new ArrayList<String>();
arrayList.add("a");
arrayList.add("b");
Iterator<String> iterator= arrayList.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
arrayList.add("c");
}
}
}
An unordered array has a search time complexity of:
Anonymous Quiz
33%
O(log n)
24%
O(n)
39%
O(n+1)
3%
O(1)
The add and remove method in TreeSet have a time complexity of:
Anonymous Quiz
7%
O(n)
34%
O(n+1)
31%
O(1)
28%
O(log n)
After resizing, size of ArrayList is increased by :
Anonymous Quiz
22%
200%
41%
50%
31%
100%
6%
None of these
After resizing, size of Vector is increased by:
Anonymous Quiz
9%
200%
44%
100%
31%
50%
16%
None of these