Question 1
Which of the following is used to insert an element into a std::queue in C++ STL?
insert()
push()
add()
enqueue()
Question 2
What will be the output of the following C++ code?
#include <iostream>
#include <queue>
using namespace std;
int main()
{
queue<int> myqueue;
myqueue.push(30);
myqueue.push(40);
myqueue.push(10);
myqueue.push(50);
cout << myqueue.back();
return 0;
}
30
40
10
50
Question 3
Which of the following statements about the queue container is false?
It is a first-in, first-out (FIFO) data structure.
It has a front and a back, but no random access to elements.
It has a fixed size.
It is implemented as a dynamic array.
Question 4
Which of the following is/are not a valid way to initialize a queue in C++?
queue<int> q;
queue<int> q(5);
queue<int> q({1, 2, 3});
queue<int> q(q2);
Question 5
Which of the following is not a member function of the queue STL in C++?
empty()
size()
get()
push()
Question 6
What is the main property of a queue?
LIFO (last in, first out)
FIFO (first in, first out)
Both a and b
None of the above
Question 7
Which of the following is not a member function of the queue STL in C++?
pop()
push()
front()
insert()
Question 8
Can the queue STL in C++ be used to store elements of different data types?
Yes
No
Question 9
What is the complexity of the size() member function of the queue STL in C++?
O(1)
O(n)
O(log n)
O(n log n)
Question 10
Can the queue STL in C++ be used to store elements of a user-defined data type?
Yes
No
There are 10 questions to complete.