C++ Programming MCQ (Multiple Choice Questions) - SchoolingAxis

C++ Programming MCQ (Multiple Choice Questions)

 Que- Indexing of bitset variables starts from ___________ 

a. leftmost bit 

b. rightmost bit 

c. same as in an array 

d. front 


Answer- rightmost bit 


Que- What is the use of count() function in bitset? 

a. To count the number of 0's 

b. To count the number of 1's 

c. To count the number of total bits in a bitset 

d. To count the number of low bits 


Answer- To count the number of 1's 


Que- What does size() function returns? 

a. To count the number of 0's 

b. To count the number of 1's 

c. To count the number of total bits used by bitset variable 

d. To count the number of low bits 


Answer- To count the number of total bits used by bitset variable 


Que- Which of the following is correct about any() function in bitset? 

a. Returns true if the number of 1's equal to the number of 0's 

b. Returns true if any bit is set 0 

c. Returns true if any bit is set 1 

d. Returns true only if all bits are 1 


Answer- Returns true if any bit is set 1 


Que- Which of the following is correct about none() function in bitset? 

a. Returns true if any bits is set 1 

b. Returns true if all bits is set 0 

c. Returns true if the number of 1's equal to the number of 0's 

d. Returns true only if all bits are 1 


Answer- Returns true if all bits is set 0 


Que- What is the use of the set() function in bitset? 

a. Used to make alternate bits zero 

b. Used to make a bit 0 in a bitset 

c. Used to make all bits zero 

d. Used to set bit(s) in a bitset 


Answer- Used to set bit(s) in a bitset 


Que- What happens when no argument is supplied to set() function? 

a. All alternate bits are set to 1 in a bitset 

b. All bits are set to 0 in a bitset 

c. All bits are set to 1 in a bitset 

d. First bit is set to 1 


Answer- All bits are set to 1 in a bitset 


Que- What happens when only one argument is supplied to set() function? 

a. All bits are set to 1 in a bitset 

b. Bit corresponding to an argument is set to 1 

c. All alternate bits are set to 1 in a bitset 

d. First bit is set to 1 


Answer- Bit corresponding to an argument is set to 1 


Que- What is the use of reset function in bitset? 

a. Used to make alternate bits zero 

b. Used to make a bit 0 in a bitset 

c. Used to make all bits 1 

d. Used to make a bit(s) 0 in a bitset 


Answer- Used to make a bit(s) 0 in a bitset 


Que- What happens when no argument is supplied to reset() function? 

a. All bits are set to 1 in a bitset 

b. All bits are set to 0 in a bitset 

c. All alternate bits are set to 0 in a bitset 

d. First bit is set to 0 


Answer- All bits are set to 0 in a bitset 


Que- What happens when only one argument is supplied to reset() function? 

a. Bit corresponding to an argument is set to 0 

b. All bits are set to 0 in a bitset 

c. All alternate bits are set to 0 in a bitset 

d. First bit is set to 0 


Answer- Bit corresponding to an argument is set to 0 


Que- What is the use of the flip function in bitset? 

a. Used to flip bit(s) in a bitset 

b. Used to flip a bit in a bitset 

c. Used to flip all bits to 1 

d. Used to flip alternate bits 


Answer- Used to flip bit(s) in a bitset 


Que- What happens when no argument is supplied to flip() function? 

a. All alternate bits are flipped in a bitset 

b. All bits are flipped to 1 in a bitset 

c. All bits are flipped in a bitset 

d. First bit is flipped 


Answer- All bits are flipped in a bitset 


Que- What happens when only one argument is supplied to flip() function? 

a. All bits are flipped in a bitset 

b. Bit corresponding to argument bit is flipped 

c. All alternate bits are flipped in a bitset 

d. First bit is flipped 


Answer- Bit corresponding to argument bit is flipped 


Que- What is the class relationship? 

a. A relationship between classes that tells how they are related 

b. A relationship between classes that tells how much power one class has over other class 

c. A relationship between classes that tells which parts of a class is visible to other classes 

d. All of the mentioned 


Answer- All of the mentioned 


Que- How many types of class relationships are there? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 4 


Que- Which type of relationship is modelled by Inheritance? 

a. Is-A relationship 

b. Has-A relationship 

c. Part-Of relationship 

d. Belongs-to relationship 


Answer- Is-A relationship 


Que- How the relationship is made in Association? 

a. Through the objects of classes 

b. Through constructor 

c. Through destructor 

d. Through class Names 


Answer- Through the objects of classes 


Que- How many types of Association can be there between classes? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 4 


Que- Why do we need relationships between classes? 

a. To use the functionality of one class into other 

b. To enhance the communication between classes 

c. To increase code re-usability 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Composition is also a type of _______________ relationship. 

a. Aggregation 

b. Association 

c. Inheritance 

d. Both Aggregation an Association 


Answer- Association 


Que- Which type of relationship is modelled by Composition? 

a. Is-A relationship 

b. Has-A relationship 

c. Part-Of relationship 

d. Have-A relationship 


Answer- Part-Of relationship 


Que- Which type of relationship is modelled by Aggregation? 

a. Is-A relationship 

b. Has-A relationship 

c. Part-Of relationship 

d. Have-A relationship 


Answer- Has-A relationship 


Que- Which of the following relationships is uni-directional? 

a. Aggregation 

b. Association 

c. Composition 

d. Both Aggregation and Composition 


Answer- Both Aggregation and Composition 


Que- In which of the following relationship objects of related classes can occur independently? 

a. Aggregation 

b. Association 

c. Composition 

d. Both Aggregation an Association 


Answer- Both Aggregation an Association 


Que- In which of the following relationship objects of related classes are strongly dependent? 

a. Aggregation 

b. Association 

c. Composition 

d. Both Composition an Association 


Answer- Both Composition an Association 


Que- Composition is a __________ type of Association relationship. 

a. strong 

b. weak 

c. unnecessary 

d. necessary 


Answer- strong 


Que- Aggregation is a __________ type of Association relationship. 

a. strong 

b. weak 

c. unnecessary 

d. necessary 


Answer- weak 


Que- Which type of relationship is modelled by Association? 

a. Is-A relationship 

b. Has-A relationship 

c. Part-Of relationship 

d. Have-A relationship 


Answer- Has-A relationship 


Que- Which container is used to store elements as key-value pair? 

a. map 

b. multimap 

c. unordered map 

d. all of the mentioned 


Answer- all of the mentioned 


Que- Which container can have the same keys? 

a. map 

b. multimap 

c. unordered map 

d. set 


Answer- multimap 


Que- Which container is best to keep the collection of distinct elements? 

a. multimap 

b. heap 

c. set 

d. queue 


Answer- set 


Que- Which container is used to keep priority based elements? 

a. queue 

b. stack 

c. set 

d. priority queue 


Answer- priority queue 


Que- Sets are implemented using _______________________ 

a. binary search tree 

b. red black tree 

c. avl tree 

d. heap 


Answer- binary search tree 


Que- Unordered map is implemented using _________________ 

a. binary search tree 

b. red black tree 

c. heap 

d. hash table 


Answer- hash table 


Que- Map is implemented using ____________________ 

a. binary search tree 

b. red black tree 

c. heap 

d. hash table 


Answer- red black tree 


Que- Which of the following is correct about the map and unordered map? 

a. Ordering of keys in maps whereas no such order in the unordered map 

b. Maps are implemented red-black trees whereas unordered map are implemented using hash tables 

c. Average search time in the unordered map is O(1) whereas it is O(logn) in case of maps 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which of the following queue container can expand or shrink from both directions? 

a. deque 

b. queue 

c. priority queue 

d. stack 


Answer- deque 


Que- Which of the following is correct about map and multimap? 

a. Map can have same keys whereas multimap cannot 

b. Implementation of maps and multimap are different 

c. Multimap can have same keys whereas the map cannot 

d. Average search time of map is greater than multimap 


Answer- Multimap can have same keys whereas the map cannot 


Que- What is the header file used for declaring the standard library algorithms? 

a. container 

b. algorithm 

c. library 

d. iterator 


Answer- algorithm 


Que- Pick out the correct method in the c++ standard library algorithm. 

a. mismatch 

b. maximum 

c. minimum 

d. maxmatch 


Answer- mismatch 


Que- What is the use of make_heap in the heap operation? 

a. Rearrange a heap 

b. Deform a heap 

c. Form a heap 

d. Delete a heap 


Answer- Form a heap 


Que- What is the type of the first item in the heap? 

a. Bigger than others 

b. Lower than others 

c. Mean value of the heap 

d. Equal to others 


Answer- Bigger than others 


Que- Pick out the correct library in the following choices. 

a. Search 

b. Generate 

c. Numeric 

d. All of the mentioned 


Answer- All of the mentioned 


Que- What kind of iteration does forward_list provide in C++? 

a. Uni-directional 

b. Bi-directional 

c. Multi-directional 

d. Bi-directional & Multi-directional 


Answer- Uni-directional 


Que- What does the size of the vector refers to in c++? 

a. Size of vector 

b. Type of vector 

c. Number of elements 

d. Name of vector 


Answer- Number of elements 


Que- Subsequent elements are moved in terms of _____ when an element in inserted in vector? 

a. Assignment Operator 

b. Copy constructor 

c. Both assignment operator and copy constructor 

d. destructor 


Answer- Both assignment operator and copy constructor 


Que- What is the use of adapter in STL in c++? 

a. To provide interface 

b. To manipulate the data 

c. To extract the data 

d. To delete the data 


Answer- To provide interface 


Que- Which is used to iterate over container? 

a. Associated iterator type 

b. Data type of objects 

c. Return type of variables 

d. Name of the variables 


Answer- Associated iterator type 


Que- What does the function objects implement? 

a. operator 

b. operator() 

c. operand 

d. operand<> 


Answer- operator() 


Que- What are the two advantage of function objects than the function call? 

a. It contains a state 

b. It is a type 

c. It contains a state & It is a type 

d. It contains a prototype 


Answer- It contains a state & It is a type 


Que- Which header is need to be used with function objects? 

a. <function> 

b. <functional> 

c. <funct> 

d. <functionstream> 


Answer- <functional> 


Que- Which are instances of a class with member function operator() when it is defined? 

a. function objects 

b. member 

c. methods 

d. iterators 


Answer- function objects 


Que- How many parameters does a operator() in a function object shoud take? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- How does a sequence of objects are accessed in c++? 

a. Iterators 

b. Pointers 

c. Both Iterators & Pointers 

d. Objects 


Answer- Both Iterators & Pointers 


Que- How many parameters are present in mismatch method in non-sequence modifying algorithm? 

a. 1 

b. 2 

c. 3 

d. 3 or 4 


Answer- 3 or 4 


Que- What will happen in 'all_of' method if the range is empty? 

a. Return true 

b. Return false 

c. Return nothing 

d. Return error 


Answer- Return true 


Que- To what kind of elements does non-modifying sequence algorithm can be applied? 

a. Range 

b. Vector 

c. List 

d. Methods 


Answer- Range 


Que- Pick out the incorrect method in non-modifying sequence algorithm? 

a. find-if 

b. none-of 

c. any-of 

d. like 


Answer- like 


Que- What is the use of middle parameter in the rotate method? 

a. Marks the begining of a sequence 

b. Marks the ending of a sequence 

c. Marks the elements in a sequence 

d. Marks the digits in a sequence 


Answer- Marks the elements in a sequence 


Que- What kind of object is modifying sequence algorithm? 

a. Function template 

b. Class template 

c. Method 

d. Iterator 


Answer- Function template 


Que- How the sequence of objects can be accessed? 

a. Iterators 

b. Pointers 

c. Both Iterators & Pointers 

d. Library 


Answer- Both Iterators & Pointers 


Que- How many kind of operation can be applied to transform method in c++? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- What is meant by sequence point? 

a. Represent the point of execution in the program 

b. Represent the whole program 

c. Represent the beginning of the program 

d. Represent the end of the program 


Answer- Represent the point of execution in the program 


Que- Pick out the correct statement about sequence point. 

a. Sequence point will compile the program 

b. Sequence point will resolve all the side effects 

c. Sequence point will save the program for execution 

d. Sequence point will delete the program for execution 


Answer- Sequence point will resolve all the side effects 


Que- In sequence point, how will the overloaded operators behave like? 

a. Function 

b. Objects 

c. Instance variable 

d. Container 


Answer- Function 


Que- What do input and output objects support? 

a. Terminated sequences 

b. Extracted sequences 

c. Null-terminated sequences 

d. Terminated & Extracted sequences 


Answer- Null-terminated sequences 


Que- What kind of execution does sequence point allow? 

a. Non-overlap 

b. Overlap 

c. Concurrent 

d. Sequence 


Answer- Non-overlap 


Que- When does the next sequence point start? 

a. At the beginning 

b. After a terminating semicolon 

c. It is a beginning statement 

d. At the end 


Answer- After a terminating semicolon 


Que- What is meant by heap? 

a. Used for fast retrieval of elements 

b. Used for organising the elements 

c. Used for fast retrieval & organising the elements 

d. Used for deleting the elements 


Answer- Used for fast retrieval & organising the elements 


Que- Which value is pointed out first in heap? 

a. Lowest value 

b. Highest value 

c. First value 

d. Third value 


Answer- Highest value 


Que- Which operator is used to compare the elements in heap? 

a. >> 

b. comp 

c. < 

d. Both comp &< 


Answer- Both comp &< 


Que- How to protect the heap from affecting the memory? 

a. Avoid using pointers for associating two data structures 

b. Embed pointed child objects into the parent object 

c. Allocate objects in chunks 

d. All of the mentioned 


Answer- All of the mentioned 


Que- In what form does the STL provides heap? 

a. queue 

b. list 

c. vector 

d. priority_queue 


Answer- priority_queue 


Que- How many types are there in binary heaps? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- Which keyword is used to declare the min and max functions? 

a. iostream 

b. string 

c. algorithm 

d. iterator 


Answer- algorithm 


Que- What kind of functions are min and max in c++? 

a. Type specific 

b. Variable specific 

c. Type & Variable specific 

d. Iterator 


Answer- Type specific 


Que- How many parameters are needed for minmax function? 

a. 1 

b. 2 

c. 3 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which function is used to return the minimum element in the range? 

a. min 

b. minimum 

c. min_element 

d. max_element 


Answer- min_element 


Que- Which operator is used to compare the values to find min and max? 

a. < 

b. > 

c. << 

d. >> 


Answer- < 


Que- What is meant by permutation in c++? 

a. To find all the values in the range 

b. To find all the combination of the range 

c. To find all the values & combination in the range 

d. To delete all the values 


Answer- To find all the combination of the range 


Que- How the different permutations are ordered in c++? 

a. Compare lexicographically to each other elements 

b. By finding the highest element in the range 

c. By finding the lowest element in the range 

d. By deleting the lowest element in the range 


Answer- Compare lexicographically to each other elements 


Que- Pick out the correct statement about permutation. 

a. If the function can determine the next higher permutation, Returns false 

b. If the function can determine the next higher permutation, Returns true 

c. If the function can't determine the next higher permutation, Returns true 

d. If the function can determine the lower higher permutation, Returns true 


Answer- If the function can determine the next higher permutation, Returns true 


Que- What is the header file for vector permutation? 

a. vector_permutation.h 

b. vector_perm 

c. <algorithm> 

d. vector_permutation 


Answer- <algorithm> 


Que- How many parameters are required for next_permutation? 

a. 1 

b. 2 

c. 2 or 3 

d. 3 


Answer- 2 or 3 


Que- Pick out the in correct type of function in <algorithm> header file. 

a. Partitions 

b. Sort 

c. Merge 

d. Join 


Answer- Join 


Que- What type of algorithm is not available in creating our own STL style algorithms? 

a. copy_if() 

b. remove_copy_if() 

c. sort 

d. remove_copy() 


Answer- copy_if() 


Que- What is meant by hash tables in C++? 

a. Array data structure 

b. Keyed array data structure 

c. Data structure 

d. Linear probing 


Answer- Keyed array data structure 


Que- What is the use of includes function in c++? 

a. Compares two ranges of data 

b. Compares two sorted ranges of data 

c. Includes a new element in the range 

d. Includes a new element in the end 


Answer- Compares two sorted ranges of data 


Que- How many parameters are required for sort_heap function? 

a. 1 

b. 2 

c. 2 or 3 

d. 3 


Answer- 2 or 3 


Previous Post Next Post

Responsive Ad