Quiz on Collections in Java
Free Java courses with 37 real-time projects - Learn Java
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
- Question 1 of 15
1. Question
Which exception is raised when a null object is passed to a collection class in Java ?
CorrectIncorrect - Question 2 of 15
2. Question
class HashTable {
public static void main ( String args [ ] )
{
HashTable < Integer , String > table = new HashTable();
table.put(1,”one”);
table.put(2.”two”);
table.put(3,”three”);
System.out.println(table.get(5));
}
}
What is the output of the program ?
CorrectIncorrect - Question 3 of 15
3. Question
class Array {
public void method( int x )
{
ArrayList<Integer> a = new Arraylist();
for(i=x;i<=5;i++)
{
a.add(i);
}
System.out.println(a);
}
class Main {
public static void main ( String args [ ] )
{
Array obj = new Array();
obj.method(2);
}
}
What is the output of the program ?
CorrectIncorrect - Question 4 of 15
4. Question
Which method in collection class is used to copy from one list to another list to another ?
CorrectIncorrect - Question 5 of 15
5. Question
class Demo {
public static void main ( String args [ ] )
{
LinkedList < String > l = new LinkedList();
for(i=1;i<5;i++)
{
l.add(i);
}
l.remove(2);
System.out.println(l);
}
}
What is the output of the program ?
CorrectIncorrect - Question 6 of 15
6. Question
class Function {
public static void main ( String args [ ] )
{
Vector <Integer> v = new Vector();
v.addElement(10);
v.addElement(25);
v.addElement(40);
public void show()
{
System.out.println(v.size());
}
show();
}
}
What is the output of the program ?
CorrectIncorrect - Question 7 of 15
7. Question
Which of the following is not a class present in collections in Java ?
CorrectIncorrect - Question 8 of 15
8. Question
class HashError {
public static void main ( String args [ ] )
{
HashTable <String> hash = new HashTable();
hash.put(“DataFlair”);
hash.put(“Webservices”);
System.out.println(hash);
}
}
What is the output of the program ?
CorrectIncorrect - Question 9 of 15
9. Question
class Sample {
public static void main ( String args [ ] )
{
Queue <Integer> q = new PriorityQueue();
q.add(10);
q.add(5);
q.add(15);
System.out.println(q;
}
}
What is the output of the program ?
CorrectIncorrect - Question 10 of 15
10. Question
What is the function of Checkedset in collections ?
CorrectIncorrect - Question 11 of 15
11. Question
class Main {
public static void main ( String args [ ] )
{
Stack<String> s = new Stack();
s.push(“Data”);
s.push(“Flair”);
s.push(“Web”);
s.push(“Services”);
s.push(“private”);
s.push(“limited”);
s.pop();
s.pop();
System.out.println(s);
}
}
What is the output of the program ?
CorrectIncorrect - Question 12 of 15
12. Question
class Linked {
public static void main ( String args [ ] )
{
LinkedList <int> list = LinkedList();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
System.out.println(list);
}
}
What is the error in the program ?
CorrectIncorrect - Question 13 of 15
13. Question
Which method is used to traverse an element in Collection classes in java ?
CorrectIncorrect - Question 14 of 15
14. Question
class Hash {
public static void main ( String args [ ] )
{
Hashtable < Integer , String > h = new Hashtable ();
h.put(10,”ten”);
h.put(20,”twenty”);
h.put(30,”thirty”);
System.out.println(h.get(10);
}
}
What is the output of the program ?
CorrectIncorrect - Question 15 of 15
15. Question
class Vector {
public static void main ( String args [ ] )
{
Vector<Integer> v = new Vector<Integer>();
v.addElement(10);
v.addElement(5);
v.addElement(3);
v.removeElement(3);
System.out.println(v);
}
}
What is the output of the program ?
CorrectIncorrect
Your opinion matters
Please write your valuable feedback about DataFlair on Google