Sail E0 Webinar

MCQs

Total Questions : 10
Question 1.

Which are the parameters for the content of the buffer?


  1.    start
  2.    finish
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> Both a & b

The contents of the buffer are initialized using the values from the iterator range supplied to 

the constructor by the start and finish parameters.


Question 2.

Which of the following type does the container should define?


  1.    Iterator type
  2.    Vector type
  3.    Storage type
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Iterator type

Every container must define an iterator type. Iterators allow algorithms to iterate over the 

container's contents.


Question 3.

How the member functions in the container can be accessed?


  1.    Iterator
  2.    Indirect
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Iterator

The container manages the storage space for its elements and provides member functions 

to access them, either directly or through iterators which reference objects with similar 

properties to pointers.


Question 4.

Which is used for manually writing lookup table?


  1.    std:map
  2.    std:lookup
  3.    std:find
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> std:map

None.


Question 5.


What is the output of this program?


1.
#include
2.
#include
3.
#include
4.
#include
5.
using namespace std;
6.
template
7.
class SimpleContainer
8.
{
9.
public:
10.
SimpleContainer(size_t xDim, size_t yDim, myType const& defaultValue)
11.
: objectData(xDim * yDim, defaultValue)
12.
, xSize(xDim)
13.
, ySize(yDim)
14.
{
15.
}
16.
myType& operator()(size_t x, size_t y)
17.
{
18.
return objectData[y * xSize + x];
19.
}
20.
myType const& operator()(size_t x, size_t y) const
21.
{
22.
return objectData[y * xSize + x];
23.
}
24.
int getSize()
25.
{
26.
return objectData.size();
27.
}
28.
void inputEntireVector(vector inputVector)
29.
{
30.
objectData.swap(inputVector);
31.
}
32.
void printContainer(ostream& stream)
33.
{
34.
copy(objectData.begin(),
objectData.end(),
35.
ostream_iterator(stream, ""/*No Space*/));
36.
}
37.
private:
38.
vector objectData;
39.
size_t xSize;
40.
size_t ySize;
41.
};
42.
template
43.
inline ostream& operator
  1.    2000
  2.    No Space
  3.    Error
  4.    Depends on the compiler
 Discuss Question
Answer: Option D. -> Depends on the compiler

In this program, We formed a simple container and got the size of it and printing it.
Output:
$ g++ cont1.cpp
$ a.out
200


Question 6.

Which container provides random access iterators?


  1.    vector
  2.    deque
  3.    sort
  4.    Both a & b
 Discuss Question
Answer: Option D. -> Both a & b

None.


Question 7.


What is the output of this program?


1.
#include
2.
#include
3.
using namespace std;
4.
class Component
5.
{
6.
public:
7.
virtual void traverse() = 0;
8.
};
9.
class Leaf: public Component
10.
{
11.
int value;
12.
public:
13.
Leaf(int val)
14.
{
15.
value = val;
16.
}
17.
void traverse()
18.
{
19.
cout traverse();
34.
}
35.
};
36.
int main()
37.
{
38.
Composite containers[4];
39.
for (int i = 0; i 40.
for (int j = 0; j 41.
containers[i].add(new Leaf(i *3+j));
42.
for (int k = 1; k 43.
containers[0].add(&(containers[k]));
44.
for (int p = 0; p 45.
{
46.
containers[p].traverse();
47.
}
48.
}
  1.    345
  2.    678
  3.    901
  4.    None of the mentioned
 Discuss Question
Answer: Option D. -> None of the mentioned

In this program, We are choosing and printing the numbers based on the certain limit and this 

is a composite design pattern.
Output:
$ g++ cont.cpp
$ a.out
0 1 2 3 4 5 6 7 8 9 10 11
3 4 5
6 7 8
9 10 11


Question 8.

How many sets of requirements are need in designing a container?


  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option C. -> 3

There are three sets of requirements. They are container interface requirements, Allocator 

interface requirements and iterator requirements.


Question 9.

Which interface in the container is required for storage management?


  1.    Memory management
  2.    Allocater interface
  3.    Memory interface
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> Allocater interface

None.


Question 10.

Which is present in the basic interface of the allocator interface?


  1.    Set of typedefs
  2.    A pair of allocation functions
  3.    allocate()
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned

The basic interface of an allocator class consists of a set of typedefs, a pair of allocation functions, 

allocate() and deallocate() and a pair of construction/destruction members, construct() and destroy().


Latest Videos

Latest Test Papers