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

C++ Programming MCQ (Multiple Choice Questions)

 Que- What is a virtual function in C++? 

a. Any member function of a class 

b. All functions that are derived from the base class 

c. All the members that are accessing base class data members 

d. All the functions which are declared in the base class and is re-defined/overridden by the derived class 


Answer- All the functions which are declared in the base class and is re-defined/overridden by the derived class 


Que- Which is the correct syntax of declaring a virtual function? 

a. virtual int func(); 

b. virtual int func(){}; 

c. inline virtual func(); 

d. inline virtual func(){}; 


Answer- virtual int func(); 


Que- Which statement is incorrect about virtual function. 

a. They are used to achieve runtime polymorphism 

b. They are used to hide objects 

c. Each virtual function declaration starts with the virtual keyword 

d. All of the mentioned 


Answer- They are used to hide objects 


Que- The concept of deciding which function to invoke during runtime is called ______________________ 

a. late binding 

b. dynamic linkage 

c. static binding 

d. both late binding and dynamic linkage 


Answer- both late binding and dynamic linkage 


Que- What is a pure virtual function? 

a. A virtual function defined inside the base class 

b. A virtual function that has no definition relative to the base class 

c. A virtual function that is defined inside the derived class 

d. Any function that is made virtual 


Answer- A virtual function that has no definition relative to the base class 


Que- What is the order of Constructors call when the object of derived class B is declared, provided class B is derived from class A? 

a. Constructor of A followed by B 

b. Constructor of B followed by A 

c. Constructor of A only 

d. Constructor of B only 


Answer- Constructor of A followed by B 


Que- What is the order of Destructors call when the object of derived class B is declared, provided class B is derived from class A? 

a. Destructor of A followed by B 

b. Destructor of B followed by A 

c. Destructor of A only 

d. Destructor of B only 


Answer- Destructor of B followed by A 


Que- Virtual functions in C++ tells the compiler to perform ______________________ on such functions. 

a. static binding 

b. late binding 

c. compile time binding 

d. no binding 


Answer- late binding 


Que- Which concept of OOPs is shown by Virtual Functions? 

a. Inheritance 

b. Encapsulation 

c. Polymorphism 

d. Abstraction 


Answer- Polymorphism 


Que- Pick the correct statement. 

a. Virtual function can have different names in the base and derived class 

b. Virtual function cannot be applied in Multiple Inheritance classes 

c. Virtual function are different in definitions only 

d. Virtual function does early binding 


Answer- Virtual function are different in definitions only 


Que- Which access specifier is used where one wants data members to be accessed by other classes but not from outside objects? 

a. private 

b. protected 

c. public 

d. both protected and public 


Answer- protected 


Que- Which of the following describes the protected access specifier? 

a. The variable is visible only outside inside the block 

b. The variable is visible everywhere 

c. The variable is visible to its block and to it's derived class 

d. The variable is not visible to its block 


Answer- The variable is visible to its block and to it's derived class 


Que- To which of the following access specifiers are applicable? 

a. Member data 

b. Functions 

c. Both Member data & Functions 

d. Protected members 


Answer- Both Member data & Functions 


Que- Members of which access specifiers are not inherited? 

a. Public 

b. Protected 

c. Private 

d. None of the mentioned 


Answer- None of the mentioned 


Que- What is the importance of mutable keyword? 

a. It allows the data member to change within a const member function 

b. It will not allow the data member to change within a const member function 

c. It will copy the values of the variable 

d. It allows the data member to change outside a const member function 


Answer- It allows the data member to change within a const member function 


Que- What is the Run-Time Type Information? 

a. Information about an object's data type at runtime 

b. Information about the variables 

c. Information about the given block 

d. Information about the functions 


Answer- Information about an object's data type at runtime 


Que- Which operators are part of RTTI? 

a. dynamic_cast() 

b. typeid 

c. both dynamic_cast<> & typeid 

d. dynamic_cast[] 


Answer- both dynamic_cast<> & typeid 


Que- To which type of class, We can apply RTTI? 

a. Encapsulation 

b. Polymorphic 

c. Derived 

d. Static 


Answer- Polymorphic 


Que- What is meant by type_info? 

a. Used to hold the type information returned by the typeid operator 

b. Used to hold the type information returned by the dynamic_cast 

c. Used to hold the type information returned by the static_cast 

d. Used to hold the type information returned by the static_id 


Answer- Used to hold the type information returned by the typeid operator 


Que- At which time does the static_cast can be applied? 

a. Compile-time construct 

b. Runtime construct 

c. Both Compile-time & Runtime construct 

d. Runtime deconstruct 


Answer- Compile-time construct 


Que- Which is referred by pointers to member? 

a. Static members of class objects 

b. Non-static members of class objects 

c. Referring to whole class 

d. Dynamic members of class objects 


Answer- Non-static members of class objects 


Que- What should be used to point to a static class member? 

a. Smart pointer 

b. Dynamic pointer 

c. Normal pointer 

d. Static pointer 


Answer- Normal pointer 


Que- Which operator is used in pointer to member function? 

a. .* 

b. ->* 

c. Both .* & ->* 

d. $* 


Answer- Both .* & ->* 


Que- Which is the best design choice for using pointer to member function? 

a. Interface 

b. Class 

c. Structure 

d. Block 


Answer- Interface 


Que- What is the operation for .*? 

a. It combines the first operand and the second operand 

b. It separates the first operand and the second operand 

c. It reduces the data size 

d. It combines the first operand and the second operand and terminates third operand 


Answer- It combines the first operand and the second operand 


Que- Which is used to allocate and deallocate storage for objects during the execution? 

a. Stack 

b. Heap 

c. Freestore 

d. Queue 


Answer- Freestore 


Que- Which operators are used in the free store? 

a. new 

b. delete 

c. both new & delete 

d. terminate 


Answer- both new & delete 


Que- What type of class member is operator new? 

a. static 

b. dynamic 

c. const 

d. smart 


Answer- static 


Que- What must be an operand of operator delete? 

a. Pointer 

b. Array 

c. Stack 

d. Queue 


Answer- Pointer 


Que- How can object be allocated outside the object lifetime? 

a. int 

b. float 

c. void* 

d. char$ 


Answer- void* 


Que- Pick out the wrong header file about strings. 

a. <string> 

b. <regex> 

c. <ios> 

d. <reg> 


Answer- <ios> 


Que- Which is best for coding the standard library for c++? 

a. no trailing underscores on names 

b. complex objects are returned by value 

c. have a member-swap() 

d. all of the mentioned 


Answer- all of the mentioned 


Que- What is meant by vector in the container library contains? 

a. It is a sequence container that encapsulates dynamic size arrays 

b. It is a sequence container that encapsulates static size arrays 

c. It manages the memory 

d. It manages the length and size 


Answer- It is a sequence container that encapsulates dynamic size arrays 


Que- Pick out the wrong header file. 

a. <algorithm> 

b. <containers> 

c. <iterators> 

d. <process> 


Answer- <process> 


Que- What is meant by standard c++ library? 

a. It is the collection of class definitions for standard data structures and a collection of algorithms 

b. It is a header file 

c. Collection of algorithms 

d. Step by step process 


Answer- It is the collection of class definitions for standard data structures and a collection of algorithms 


Que- Pick out parameter for rehash method in unordered_set in c++? 

a. count 

b. size 

c. hash 

d. type 


Answer- count 


Que- What is the use of <exception> header 

a. Contains the standard exception files 

b. Contains the standard library files 

c. It is used to arise an exception in the program 

d. Reduce the memory size 


Answer- Contains the standard exception files 


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

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- Which interface in the container is required for storage management? 

a. Memory management 

b. Allocator interface 

c. Memory interface 

d. Storage interface 


Answer- Allocator interface 


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

a. Set of typedefs 

b. A pair of allocation functions 

c. allocate() 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which container provides random access iterators? 

a. vector 

b. deque 

c. sort 

d. both vector & deque 


Answer- both vector & deque 


Que- Which is used for manually writing lookup table? 

a. std:map 

b. std:lookup 

c. std:find 

d. std:lock 


Answer- std:map 


Que- How can the member functions in the container be accessed? 

a. Iterator 

b. Indirect 

c. Both Iterator & Indirect 

d. Vector 


Answer- Iterator 


Que- Which of the following type does the container should define? 

a. Iterator type 

b. Vector type 

c. Storage type 

d. Memory type 


Answer- Iterator type 


Que- Which are the parameters for the content of the buffer? 

a. start 

b. finish 

c. both start & finish 

d. pause 


Answer- both start & finish 


Que- What do vectors represent? 

a. Static arrays 

b. Dynamic arrays 

c. Stack 

d. Queue 


Answer- Dynamic arrays 


Que- In which type of storage location are the vector members stored? 

a. Contiguous storage locations 

b. Non-contiguous storage locations 

c. Contiguous & Non-contiguous storage locations 

d. Memory storage locations 


Answer- Contiguous storage locations 


Que- How many vector container properties are there in c++? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- Pick out the correct statement about vector. 

a. vector<int> values (5) 

b. vector values (5) 

c. vector<int> (5) 

d. vector<5> 


Answer- vector<int> values (5) 


Que- Which is optional in the declaration of vector? 

a. Type 

b. Name 

c. Vector 

d. Number_of_elements 


Answer- Number_of_elements 


Que- How many items are there in sequence container? 

a. 2 

b. 3 

c. 4 

d. 5 


Answer- 5 


Que- Which of the following class template are based on arrays? 

a. vector 

b. list 

c. dequeue 

d. both vector & dequeue 


Answer- both vector & dequeue 


Que- Which of the following will return the new element at the end of container? 

a. front 

b. back 

c. push_back 

d. pop_back 


Answer- back 

Previous Post Next Post

Responsive Ad