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

C++ Programming MCQ (Multiple Choice Questions)

 Que- Which value is placed in the base class? 

a. derived values 

b. default type values 

c. both default type & derived values 

d. null value 


Answer- default type values 


Que- How many bits of memory needed for internal representation of class? 

a. 1 

b. 2 

c. 4 

d. no memory needed 


Answer- no memory needed 


Que- What is the Standard Template Library? 

a. Set of C++ template classes to provide common programming data structures and functions 

b. Set of C++ classes 

c. Set of Template functions used for easy data structures implementation 

d. Set of Template data structures only 


Answer- Set of C++ template classes to provide common programming data structures and functions 


Que- Pick the correct statement. 

a. STL is a generalized library 

b. Components of STL are parameterized 

c. STL uses the concept of templates classes and functions to achieve generalized implementation 

d. All of the mentioned 


Answer- All of the mentioned 


Que- How many components STL has? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 4 


Que- What are the containers? 

a. Containers store objects and data 

b. Containers stores all the algorithms 

c. Containers contain overloaded functions 

d. Containers contain set of Iterators 


Answer- Containers store objects and data 


Que- In how many categories, containers are divided? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 4 


Que- What are the Sequence Containers? 

a. Containers that implements data structures which can be accessed sequentially 

b. Containers that implements sorted data structures for fast search in O(logn) 

c. Containers that implements unsorted(hashed) data structures for quick search in O(1) 

d. Containers that implements data structures which can be accessed non-sequentially 


Answer- Containers that implements data structures which can be accessed sequentially 


Que- How many Sequence Containers are provided by C++? 

a. 2 

b. 3 

c. 4 

d. 5 


Answer- 5 


Que- What are the Associative Containers? 

a. Containers that implements data structures which can be accessed sequentially 

b. Containers that implements sorted data structures for fast search in O(logn) 

c. Containers that implements unsorted(hashed) data structures for quick search in O(1) 

d. Containers that implements data structures which can be accessed non-sequentially 


Answer- Containers that implements sorted data structures for fast search in O(logn) 


Que- How many Associative Containers are provided by C++? 

a. 2 

b. 3 

c. 4 

d. 5 


Answer- 4 


Que- What are Unordered Associative Containers? 

a. Containers that implements data structures which can be accessed sequentially 

b. Containers that implements sorted data structures for fast search in O(logn) 

c. Containers that implements unsorted(hashed) data structures for quick search in O(1) 

d. Containers that implements data structures which can be accessed non-sequentially 


Answer- Containers that implements unsorted(hashed) data structures for quick search in O(1) 


Que- What are Container Adaptors? 

a. Containers that implements data structures which can be accessed sequentially 

b. Containers that implements sorted data structures for fast search in O(logn) 

c. Containers that implements unsorted(hashed) data structures for quick search in O(1) 

d. Containers that provide a different interface for sequential containers 


Answer- Containers that provide a different interface for sequential containers 


Que- How many Container Adaptors are provided by C++? 

a. 2 

b. 3 

c. 4 

d. 5 


Answer- 3 


Que- What are Iterators? 

a. Iterators are used to iterate over C-like arrays 

b. Iterators are used to iterate over pointers 

c. Iterators are used to point memory addresses of STL containers 

d. Iterators are used to iterate over functions 


Answer- Iterators are used to point memory addresses of STL containers 


Que- How many types of Iterators are provided by C++? 

a. 2 

b. 3 

c. 4 

d. 5 


Answer- 5 


Que- Which header file is used for Iterators? 

a. <iterator> 

b. <algorithm> 

c. <iter> 

d. <loopIter> 


Answer- <iterator> 


Que- Which of the following is used for generic programming? 

a. Virtual functions 

b. Modules 

c. Templates 

d. Abstract Classes 


Answer- Templates 


Que- Which of the following is correct about templates? 

a. It is a type of compile time polymorphism 

b. It allows the programmer to write one code for all data types 

c. Helps in generic programming 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which of the following is used for generic programming? 

a. Virtual functions 

b. Modules 

c. Templates 

d. Abstract Classes 


Answer- Templates 


Que- Which of the following is correct about templates? 

a. It is a type of compile time polymorphism 

b. It allows the programmer to write one code for all data types 

c. Helps in generic programming 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which keyword is used to handle the expection? 

a. try 

b. throw 

c. catch 

d. handler 


Answer- catch 


Que- Which is used to throw a exception? 

a. throw 

b. try 

c. catch 

d. handler 


Answer- throw 


Que- What is the use of the 'finally' keyword? 

a. It used to execute at the starting of the program 

b. It will be executed at the end of the program even if the exception arised 

c. It will be executed at the starting of the program even if the exception arised 

d. It will be executed at the middle of the program even if the exception arised 


Answer- It will be executed at the end of the program even if the exception arised 


Que- How do define the user-defined exceptions? 

a. inheriting and overriding exception class functionality 

b. overriding class functionality 

c. inheriting class functionality 

d. delting and adding class member 


Answer- inheriting and overriding exception class functionality 


Que- Which exception is thrown by dynamic_cast? 

a. bad_cast 

b. bad_typeid 

c. bad_exception 

d. bad_alloc 


Answer- bad_cast 


Que- How many types of exception handling are there in c++? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- How many runtime error messages associated with exception? 

a. 2 

b. 4 

c. 5 

d. infinite 


Answer- 4 


Que- Which block should be placed after try block? 

a. catch 

b. throw 

c. either catch or throw 

d. handler 


Answer- catch 


Que- Pick out the correct answer. 

a. Exceptions are not suitable for critical points in code 

b. Exception are suitable for critical points in code 

c. Exceptions are used when postconditions of a function cannot be satisfied 

d. Throw block should be placed after try block 


Answer- Exceptions are not suitable for critical points in code 


Que- When exceptions are used? 

a. To preserve the program 

b. Exceptions are used when postconditions of a function cannot be satisfied 

c. Exceptions are used when postconditions of a function can be satisfied 

d. Exceptions are used when preconditions of a function cannot be satisfied 


Answer- Exceptions are used when postconditions of a function can be satisfied 


Que- How many parameters does the throw expression can have? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 1 


Que- Where exception are handled? 

a. inside the program 

b. outside the regular code 

c. both inside or outside 

d. main program 


Answer- outside the regular code 


Que- Which is used to check the error in the block? 

a. try 

b. throw 

c. catch 

d. handler 


Answer- try 


Que- How to handle the exception in constructor? 

a. We have to throw an exception 

b. We have to return the exception 

c. We have to throw an exception & return the exception 

d. We have to catch an exception 


Answer- We have to throw an exception 


Que- What should present when throwing a object? 

a. constructor 

b. copy-constructor 

c. destructor 

d. copy-destructor 


Answer- copy-constructor 


Que- What can go wrong in resource management on c++? 

a. Leakage 

b. Exhaustion 

c. Dangling 

d. Exception 


Answer- Exception 


Que- When do we call that resource is leaked? 

a. Arise of compile time error 

b. It cannot be accessed by any standard mean 

c. Arise of runtime error 

d. It can be accessed by any standard mean 


Answer- It cannot be accessed by any standard mean 


Que- What kind of error can arise when there is a problem with memory? 

a. Segmentation fault 

b. Produce an error 

c. Both Segmentation fault & Produce an error 

d. runtime error 


Answer- Segmentation fault 


Que- What is meant by garbage collection? 

a. The form of manual memory management 

b. The form of automatic memory management 

c. Used to replace the variables 

d. Used to delete the variables 


Answer- The form of automatic memory management 


Que- What are the operators available in C++ for dynamic allocation and de-allocation of memories? 

a. new 

b. delete 

c. compare 

d. both new & delete 


Answer- both new & delete 


Que- Which is used to solve the memory management problem in c++? 

a. smart pointers 

b. arrays 

c. stack 

d. queue 


Answer- smart pointers 


Que- Which is used to handle the exceptions in c++? 

a. catch handler 

b. handler 

c. exception handler 

d. throw 


Answer- exception handler 


Que- Which type of program is recommended to include in try block? 

a. static memory allocation 

b. dynamic memory allocation 

c. const reference 

d. pointer 


Answer- dynamic memory allocation 


Que- Which statement is used to catch all types of exceptions? 

a. catch() 

b. catch(Test t) 

c. catch(…) 

d. catch(Test) 


Answer- catch(…)

Previous Post Next Post