Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Collections are a fundamental concept in Java programming, providing powerful tools for managing and manipulating groups of objects. Whether you’re crafting dynamic data structures, building efficient algorithms, or organizing complex information, a solid understanding of Java collections is essential.
This interactive quiz will test your knowledge of core collection concepts and their functionalities, helping you identify areas for improvement and solidify your foundation in this critical domain.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which exception is raised when a null object is passed to a collection class in Java ?
Correct
Incorrect
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 ?
Correct
Incorrect
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 ?
Correct
Incorrect
Question 4 of 15
4. Question
Which method in collection class is used to copy from one list to another list to another ?
Correct
Incorrect
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 ?
Correct
Incorrect
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 ?
Correct
Incorrect
Question 7 of 15
7. Question
Which of the following is not a class present in collections in Java ?
Correct
Incorrect
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 ?
Correct
Incorrect
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 ?
Correct
Incorrect
Question 10 of 15
10. Question
What is the function of Checkedset in collections ?
Correct
Incorrect
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 ?
Correct
Incorrect
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 ?
Correct
Incorrect
Question 13 of 15
13. Question
Which method is used to traverse an element in Collection classes in java ?
Correct
Incorrect
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 ?
Correct
Incorrect
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 ?
Correct
Incorrect
Summary:
So you’ve taken the Java Collections Quiz and put your skills to the test! This quiz covered essential topics like exception handling with collections, null object handling, and various collection types.
By reviewing both your correct and incorrect answers, you can gain valuable insights into your strengths and weaknesses when working with Java collections.
Remember, effective learning is an ongoing process. Explore additional resources beyond the quiz to deepen your understanding. Consider online courses, tutorials, and practice problems to further solidify your grasp of Java collections and become a more proficient Java programmer.
Your opinion matters Please write your valuable feedback about DataFlair on Google
DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.