JAVA
2.7K subscribers
73 photos
111 files
76 links
Download Telegram
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
class Employee{
String name;
public Employee(){}
public Employee(String name){
this.name=name;
}
public String toString(){
return "name"+name;
}
static class comparatorName implements Comparator<Employee>{
public int compare(Employee obj1,Employee obj2){
return obj1.name.compareTo(obj2.name);
}
}
}
public class Program
{
public static void main(String[] args) {
Employee e1=new Employee("ankit");
Employee e2=new Employee("brad");

ArrayList<Employee> list=new ArrayList<Employee>();
list.add(e1);
list.add(e2);
Collections.sort(list,new Employee.comparatorName());
System.out.println(list);
}
}
What guarantees type-safety in a collection?
Anonymous Quiz
42%
Generics
26%
Abstract classes
29%
Interface
3%
Collection
HashSet internally uses?
Anonymous Quiz
32%
Set
56%
HashMap
7%
List
5%
Collection
The most used interfaces from the Collection framework are?
Anonymous Quiz
23%
List
15%
Map
5%
Set
56%
All of these
The root interface of Java Collection framework hierarchy is -
Anonymous Quiz
51%
Collection
5%
Root
35%
Collections
8%
List/Set
Which of these is synchronized?
Anonymous Quiz
13%
ArrayList
38%
LinkedList
33%
Vector
18%
None of these
ArrayList implements which of the following?
Anonymous Quiz
32%
List
18%
RandomAccess
13%
Cloneable
37%
All of these
Which of these allows the storage of many null values?
Anonymous Quiz
5%
Set
55%
List
21%
None of these
18%
All of these
nextIndex() and previousIndex() are methods of which interface?
Anonymous Quiz
13%
IndexIterator
23%
Iterator
48%
ListIterator
16%
NextPreviousIterator
Vector extends which of these?
Anonymous Quiz
19%
ArrayList
25%
LinkedList
42%
AbstractList
14%
None
LinkedList implements?
Anonymous Quiz
20%
Deque
45%
List
3%
None
33%
All
In Iterator, nextElement() method of Enumeration has been changed to:
Anonymous Quiz
42%
next()
35%
getNext()
19%
returnNext()
3%
name remains same
Enumeration returned by Vector is?
Anonymous Quiz
47%
fail-fast
43%
fail-safe
10%
None
From Java 5 onwards, which one of these is recommended to replace Hashtable?
Anonymous Quiz
28%
ConcurrentHashMap
38%
HashMap
34%
ConcurrentHashtable
0%
None
Which does not allow to store a null value?
Anonymous Quiz
44%
TreeSet
15%
LinkedHashSet
32%
HashSet
9%
None
Iterator returned by Vector is?
Anonymous Quiz
53%
fail-fast
43%
fail-safe
3%
None
What describes how well an algorithm performs in best, average or worse case scenarios?
Anonymous Quiz
8%
Big-B
62%
Big-O
31%
Big-Data
0%
Big-N
An ordered array has a search time complexity of?
Anonymous Quiz
26%
O(n)
32%
O(1)
39%
O(log n)
3%
O(n-1)
Which Map class must be preferred in multi-threading environment to maintain natural order of keys?
Anonymous Quiz
22%
ConcurrentHashMap
19%
ConcurrentSkipListMap
22%
ConcurrentMap
37%
All