Test Series - cpp

Test Number 66/102

Q: What is sequence container arrays?
A. C-like arrays
B. Template class sequence container, alternative for C-like arrays
C. Collection of data of the same type
D. Collection of objects
Solution: Sequence Containers arrays are an alternative for C-like arrays. It is a static continuous array that uses template classes with extended features for array implementation.
Q: Pick the correct statement.
A. Sequence Container arrays know (somehow stores within) its size whereas C-like arrays do not
B. Sequence Container arrays have no advantage over C-like arrays
C. Sequence Container arrays are same as C-like arrays
D. Sequence Container arrays are also present in C
Solution: Sequence Containers Arrays stores its size within itself so need to pass extra size parameter when passing this array as an argument.
Q: Which of the following is/are advantage(s) of Sequence Container arrays over C-like arrays?
A. Sequence Container arrays store its size within itself whereas C-like arrays do not
B. Sequence Container arrays are more efficient
C. Sequence Container arrays have no array decay problem whereas C-like arrays do have
D. All of the mentioned
Solution: Sequence Container arrays(a.k.a Array classes) somehow stores its size and it can be implemented efficiently. Also, Array classes do not have Array decay problem.
Q: Which of the follwoing function(s) of Array classes are similar to [] operator?
A. at()
B. get()
C. both at() and get()
D. front()
Solution: Both at() and get() function are used to access the elements stored at i’th position of the array.
Q: How many different ways are there to access an element of array classes at the ith position?
A. 1
B. 2
C. 3
D. 4
Solution: There are three ways of accessing Array classes as mentioned below:
i. using [] operator(same as C-like arrays)
ii. using at() function available in array classes.
iii. using get() function not a member of the array class.
Q: What header file is included to use array classes?
A. 
B. 
C. 
D. 
Solution:  header file is provided by the C++ to use array classes.
Q: What is the correct syntax of declaring an array class?
A. array arr;
B. array arr;
C. Array arr;
D. Array arr;
Solution: The declaration of array class starts with a keyword array followed by <> specifying the type and size of array and then the name of the identifier. Example: array arr; arr is an array class of type in with size = 10.
Q: Which function is used to access the first element of an array class?
A. front()
B. start()
C. back()
D. first()
Solution: Array class provides front() function to access the first element of the array class.
Q: Which function is used to access the last element of an array class?
A. end()
B. start()
C. back()
D. last()
Solution: Array class provides back() function to access the last element of the array class.
Q: Which of the following function(s) is/are used to get the size of the array class?
A. size()
B. max_size()
C. both size() and max_size()
D. get_size()
Solution: Both size() and max_size() are used to get the size of array class. There is no difference between size() and max_size() of array class.

You Have Score    /10