Java : Queue - Exercises and Solution


1. Write a Java program to create a Queue using LinkedList

View Solution

2. Write a Java program to implement Queue using ArrayDeque class

View Solution

3. Write a Java program to remove an item from the Queue

View Solution

4. Write a Java program to compare two queues

View Solution

5. Write a Java program to print Queue elements using foreach loop

View Solution

6. Write a Java program to get the size of the Queue collection

View Solution

7. Write a Java program to check whether a queue is empty or not

View Solution

8. Write a Java program to iterate Queue elements using the iterator() method

View Solution

9. Write a Java program to remove all elements of queue

View Solution

10. Write a Java program to add elements to Queue using add() and offer() methods

View Solution

11. Write a Java program to retrieve & remove an element from the head of the queue

View Solution

12. Write a Java program to retrieve an element from the head of the queue without removing it

View Solution

13. Write a Java program to Removing elements from the queue using poll() methods

View Solution

14. Write a Java program to Accessing the head of the queue using peek() methods

View Solution

15. Write a Java program to Reverse Queue using a Stack

View Solution

16. Write a Java program to Check if a queue is palindrome or not

View Solution

17. Write a Java Program to Interleave the elements of two queues

View Solution

18. Write a Java Program to Find the maximum element in a queue

View Solution

19. Write a Java Program to Find the sum of elements in a queue

View Solution

20. Write a Java Program to Find the average of elements in a queue

View Solution

21. Write a Java Program to Check if a queue contains a specific element

View Solution

22. Write a Java Program to Merge two queues

View Solution

23. Write a Java program to Reverse the order of elements in a queue without using any additional data structures

View Solution

24. write a Java program to Find the first non-repeating element in the array using a queue

View Solution

25. Write a Java program to Reverse the elements of a queue using recursion

View Solution

26. Write a Java program to Remove all occurrences of a specific element from a queue

View Solution

27. Write a Java program to Check if two queues are equal. Two queues are considered equal if they have the same elements in the same order

View Solution

28. Write a Java program to Find the minimum element in a queue without removing it from the queue

View Solution

29. Write a Java program to Reverse the first half of the elements and leave the second half unchanged

View Solution

30. Write a Java program to Find the sum of all even numbers in the queue

View Solution

31. Write a Java program to Find the sum of all odd numbers in the queue

View Solution

32. Write a Java program to Find the Longest string in the queue

View Solution

33. Write a Java program to Remove all Duplicate elements from the queue

View Solution

34. Write a Java program to Find the Product of all elements in a queue

View Solution

35. Write a Java program to Move all Even elements to the front of the queue while maintaining the relative order of other elements

View Solution

36. Write a Java program to Find the second smallest element in the queue

View Solution

37. Write a Java program to Print the all Even numbers in the queue

View Solution

38. Write a Java program to Print the all Odd numbers in the queue

View Solution

39. Write a Java program to Print the all Negative numbers in the queue

View Solution

40. Write a Java program to Print the all Positive numbers in the queue

View Solution

41. Write a Java program to Clear all elements from a queue

View Solution

42. Write a Java program to Counts the number of digits, alphabets, and special characters in a queue of strings

View Solution



Basic Programs