Site icon DataFlair

Quiz on Data Structures in java

quiz on data structures in java

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

In the exciting world of Java programming, data structures are like the filing cabinets that keep your information organized and accessible.

This quiz is your chance to test your knowledge of some of the most essential data structures – stacks, queues, and linked lists. These structures provide powerful ways to store and manipulate your data, and mastering them is crucial for building efficient and well-designed Java programs.

The quiz delves into the core operations that make these data structures so useful. You’ll be challenged on adding elements (like filing new documents), removing them (taking out old documents), and even peeking at what’s on top (checking the next document in line).

By tackling these questions, you’ll gain valuable insights into how effectively you can work with these fundamental building blocks of Java programs. So, are you ready to see how well you can organize your data structures knowledge? Take the quiz and discover areas where you excel and where you might need some extra practice!

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

    What will be displayed as output when a value not in an array is printed ?

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

     class Data {

    public static void main ( String args [ ] ) 

    {

    int arr[] = new int[10];

    for(int i = 0; i<arr.length;i++)

    {

    System.out.println(“DataFlair”);

    }

    }

    }

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

    class DataStructure {

    public static void main ( String args [ ] )

    {

    LinkedList<int> l = new LinkedList<String>();

    l.add(“DataFlair”);

    System.out.println(l);

    }

    }

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

    Which data structure in Java is recursive in nature ?

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

    class StackDemo {

    public static void main ( String args [ ] )

    {

    Stack<String> s = new Stack<String> ();

    s.push(“One”);

    s.push(“Two”);

    s.push(“Three”);

    System.out.println(s.peek());

    }

    }

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

    class QueueDemo {

    public static void main ( String args [ ] )

    {

    Queue<integer> q = new LinkedList<integer> ();

    q.add(100);

    q.add(99);

    q.add(98);

    q.add(97);

    q.add(96);

    System.out.println(q.size());

    }

    }

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

    If A is the name of a Queue in Java, which of the following is the correct syntax to add a 

        element to this queue ?

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

    class LinkedListDemo {

    public static void main ( String args [ ] )

    {

    LinkedList<Long> l = new LinkedList<Long> ();

    l.add(“641044”);

    l.add(“641037”);

    System.out.println(l.getLast());

    }

    }

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

    class StackDataStructure {

    public static void main ( String args [ ] )

    {

    Stack s = new Stack();

    s.push(1);

    s.push(1);

    s.push(2);

    s.push(3);

    s.push(5);

    s.push(8);

    s.push(13);

    s.push(21);

    if(s.size()>5) {

    s.clear();

    }

    if(s.empty==true) {

    System.out.println(“Stack is empty”);

    }

    else {

    System.out.println(“Stack is full”);

    }

    }

    }

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

    What is the function of the void clear ( ) method while using LinkedLists ?

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

     class QueueJava {

    public static void main ( String args [ ] )

    {

    Queue<Integer> data = new Queue<Integer> ();

    data.add(1);

    data.add(2);

    data.add(3);

    int deleted = data.remove();

    System.out.println(“Removed element is “ + deleted);

    }

    }

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

    class PriorityQueue {

    public static void main ( String args [ ] )

    {

    Queue<Integer> q = new PriorityQueue<Integer> ();

    q.add(10);

    q.add(3);

    q.add(45);

    q.add(7);

    q.add(18);

    System.out.println(q);

    }

    }

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

     Which of the following operations is used to remove a top element in a stack ?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

    class Array {

    public static void main ( String args [ ] )

    {

    String Array[ ] = { “welcome” , “to” , “DataFlair” , “WebServices” };

    for( int i = 0 ; i<= Array.length ; i ++ )

    {

    System.out.println(Array);

    }

    }

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

    Class Function {

    public static void main ( String args [ ] )

    {

    Stack<String> s = new Stack<String> ();

    s.push(“DataFlair”);

    s.push(“WebServices”);

    s.push(“private”);

    s.push(“limited”);

    System.out.println(s);

    s.pop();

    s.pop();

    System.out.println(s);

    }

    }

    Correct
    Incorrect

Summary:

Congratulations on taking the quiz! Whether you aced it or encountered some challenges, the valuable insights you gained are the true reward. Remember, data structures are the foundation for efficient and powerful Java programs. Use the quiz as a springboard for further exploration.

Delve deeper into stacks, queues, and linked lists through online tutorials, courses, or practice problems. There’s a wealth of resources available to solidify your understanding.

As you master these data structures, you’ll unlock the potential to build more versatile and efficient Java programs. So keep learning, keep practising, and keep building your programming skills!

Exit mobile version