Site icon DataFlair

Quiz on Collections in Java

quiz on collections in java

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.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

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

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question

    Which exception is raised when a null object is passed to a collection class in Java ?

    Correct
    Incorrect
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. Question 7 of 15
    7. Question

    Which of the following is not a class present in collections in Java ?

    Correct
    Incorrect
  8. 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
  9. 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
  10. Question 10 of 15
    10. Question

    What is the function of Checkedset in collections ?

    Correct
    Incorrect
  11. 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
  12. 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
  13. Question 13 of 15
    13. Question

     Which method is used to traverse an element in Collection classes in java ?

    Correct
    Incorrect
  14. 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
  15. 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.

Exit mobile version