InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
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» The correct choice is (d) Used to make a bit(s) 0 in a bitset Easiest explanation - |
|
| 52. |
Which of the following is correct about bitset and vector of bools?(a) Space consumed by bitset is less than vector(b) Bitset consume only 1 bit per element(c) Number of elements in bitset should be known at compile time whereas vector can have a dynamic size(d) All of the mentioned |
|
Answer» The correct option is (d) All of the mentioned Explanation: Bitset consumes less space compared to bool vector however the size for bitset is static whereas for bool vector size is dynamic. |
|
| 53. |
What is the default value of a bitset?(a) All bits are 0(b) All bits are 1(c) Leftmost bit is 0(d) Rightmost bit is 0 |
|
Answer» Correct choice is (a) All bits are 0 Explanation: By default, all the bits of a bitset variable is set to 0 i.e. the value of bitset variable is 0. |
|
| 54. |
To which type of class, We can apply RTTI?(a) Encapsulation(b) Polymorphic(c) Derived(d) Static |
|
Answer» The correct choice is (b) Polymorphic The explanation: RTTI is available only for classes which are polymorphic, which means they have at least one virtual method. |
|
| 55. |
What type of access does deque and vector provide?(a) Linear access(b) Parallel access(c) Random access(d) Memory access |
|
Answer» Right answer is (c) Random access Explanation: Because they can manipulate the values on anywhere in the program, So it is providing random access. |
|
| 56. |
What type of class template is list?(a) Class-based(b) Node-based(c) Method-based(d) size-based |
|
Answer» Correct answer is (b) Node-based For explanation: It is node-based because it allows for efficient insertion anywhere in the program. |
|
| 57. |
Which operator is used to access the nth bit in a bitset?(a) ->(b) [](c) .(d) * |
|
Answer» The correct answer is (b) [] The best I can explain: [] operator is used to access the nth bit of a bitset from the right side. For example, if my bitset b is 1010 then b[0] represents 0 and b[1] represents 1. |
|
| 58. |
To what type of object does the container can be instantiated?(a) int(b) float(c) double(d) any type of object |
|
Answer» Correct option is (d) any type of object Explanation: All type of object does the container can be instantiated. |
|
| 59. |
Which of the following syntax is used to convert any variable to its original type?(a) any_cast();(b) any_cast(variable_name);(c) (variable_name);(d) any_cast(variable_name); |
|
Answer» Right option is (d) any_cast Easiest explanation - The syntax used to convert the any variable to its original type is as follows: |
|
| 60. |
How many types of container classes are there in c++?(a) 1(b) 2(c) 3(d) As many as possible |
|
Answer» Correct option is (b) 2 To explain: There are two type of container classes in c++. They are value containers and reference containers. |
|
| 61. |
What do we return if we use simple array on a internal container?(a) Methods(b) Pointers(c) Objects(d) Values |
|
Answer» Correct option is (b) Pointers Best explanation: Pointers are legal iterators, so if your internal container is a simple C array, then all you need to do is return the pointers. |
|
| 62. |
How many iterators are needed for the defining a new container?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» The correct choice is (c) 3 Best explanation: There are three main iterators needed for designing a container. They are const iterator, Reverse iterator and Iterator traits. |
|
| 63. |
What do all STL containers define?(a) Iterator types(b) Begin methods(c) End methods(d) All of the mentioned |
|
Answer» Correct answer is (d) All of the mentioned Easy explanation - All the STL containers define the iterator types for that container, e.g., iterator and const_iterator, e.g., vector::iterator and the begin/end methods for that container, e.g., begin() and end(). |
|
| 64. |
Which keyword is used to handle the expection?(a) try(b) throw(c) catch(d) handler |
|
Answer» Correct answer is (c) catch Best explanation: When we found a exception in the program, We need to throw that and we handle that by using the catch keyword. |
|
| 65. |
What are the design requirements for building a container from the sratch?(a) Container interface requirements(b) Allocator interface requirements(c) Iterator requirements(d) All of the mentioned |
|
Answer» The correct choice is (d) All of the mentioned To explain I would say: These are the design specific requirements for building a container from the scratch. |
|
| 66. |
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» Right choice is (a) inheriting and overriding exception class functionality Best explanation: User defined exceptions can be done by inheriting and overriding the exception class functionality. |
|
| 67. |
Which is used to handle the exceptions in c++?(a) catch handler(b) handler(c) exception handler(d) throw |
|
Answer» The correct choice is (c) exception handler Explanation: Exception handler is used to handle the exceptions in c++. |
|
| 68. |
What will happen when introduce the interface of classes in a run-time polymorphic hierarchy?(a) Separation of interface from implementation(b) Merging of interface from implementation(c) Separation of interface from debugging(d) Merging of interface from debugging |
|
Answer» Right option is (a) Separation of interface from implementation The best I can explain: Separation of interface from implementation introduce the interface of classes in a run-time polymorphic hierarchy. |
|
| 69. |
Which keyword is used to throw an exception?(a) try(b) throw(c) throws(d) except |
|
Answer» Correct option is (b) throw The best I can explain: ‘throw’ keyword is used to throw exceptions if something bad happens. |
|
| 70. |
What is an error in C++?(a) Violation of syntactic and semantic rules of a languages(b) Missing of Semicolon(c) Missing of double quotes(d) Violation of program interface |
|
Answer» Correct option is (a) Violation of syntactic and semantic rules of a languages To explain I would say: An error occurs when rules and laws of a language is violated while writing programs in that language. |
|
| 71. |
An uncaught handler returns to _______________(a) main function(b) its caller(c) its callee(d) waits there for some time |
|
Answer» Right answer is (c) its callee To explain I would say: Uncaught handler returns to its callee(i.e. the function it is called by). |
|
| 72. |
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» Correct answer is (b) Containers that implements sorted data structures for fast search in O(logn) Explanation: Associative Containers is the subset of Containers that implements sorted data structures for fast search in O(logn). |
|
| 73. |
How many Sequence Containers are provided by C++?(a) 2(b) 3(c) 4(d) 5 |
|
Answer» Correct choice is (d) 5 The explanation is: C++ provides 5 types of Sequence Containers namely array, vector, deque, forward_list and list. |
|
| 74. |
In how many categories, containers are divided?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» Right option is (d) 4 The best I can explain: Containers are divided into 4 categories namely Sequence Containers, Associative Containers, Unordered Associative Containers and Container Adaptors. |
|
| 75. |
How many ways of reusing are there in the class hierarchy?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» The correct choice is (b) 2 Easiest explanation - Class hierarchies promote reuse in two ways. They are code sharing and interface sharing. |
|
| 76. |
What does inheritance allow you to do?(a) create a class(b) create a hierarchy of classes(c) access methods(d) create a method |
|
Answer» The correct choice is (b) create a hierarchy of classes For explanation: Inheritance helps in creating hierarchy of classes by making connections between different classes in which one is called base class and other is class derived class. |
|
| 77. |
How many Associative Containers are provided by C++?(a) 2(b) 3(c) 4(d) 5 |
|
Answer» Correct answer is (c) 4 Best explanation: C++ provides 4 types of Associative Containers namely Set, Map, multiset and multimap. |
|
| 78. |
Pick out the correct statement about the override.(a) Overriding refers to a derived class function that has the same name and signature as a base class virtual function(b) Overriding has different names(c) Overriding refers to a derived class(d) Overriding has different names & it refers to a derived class |
|
Answer» The correct answer is (a) Overriding refers to a derived class function that has the same name and signature as a base class virtual function The best explanation: Overriding refers to a derived class function that has the same name and signature as a base class virtual function. |
|
| 79. |
Which is the correct syntax of defining a pure virtual function?(a) pure virtual return_type func();(b) virtual return_type func() pure;(c) virtual return_type func() = 0;(d) virtual return_type func(); |
|
Answer» Right answer is (c) virtual return_type func() = 0; Easiest explanation - virtual return_type function_name(parameters) = 0; where {=0} is called pure specifier. |
|
| 80. |
Which is used to create a pure virtual function?(a) $(b) =0(c) &(d) ! |
|
Answer» Correct option is (b) =0 To explain I would say: For making a method as pure virtual function, We have to append ‘=0’ to the class or method. |
|
| 81. |
Pick out the correct statement about multiple inheritances.(a) Deriving a class from one direct base class(b) Deriving a class from more than one direct base class(c) Deriving a class from more than one direct derived class(d) Deriving a class from more than one direct derivedbase class |
|
Answer» The correct choice is (b) Deriving a class from more than one direct base class The best explanation: In multiple inheritances, We are able to derive a class from more than one base class. |
|
| 82. |
What is a pure virtual function in C++?(a) A virtual function defined in a base class(b) A virtual function declared in a base class(c) Any function in a class(d) A function without definition in a base class |
|
Answer» Right answer is (b) A virtual function declared in a base class The explanation is: Pure virtual function is a virtual function which has no definition/implementation in the base class. |
|
| 83. |
Which is the correct statement about pure virtual functions?(a) They should be defined inside a base class(b) Pure keyword should be used to declare a pure virtual function(c) Pure virtual function is implemented in derived classes(d) Pure virtual function cannot implemented in derived classes |
|
Answer» The correct option is (c) Pure virtual function is implemented in derived classes The explanation is: A pure virtual function does not have a definition corresponding to base class. All derived class may or may not have an implementation of a pure virtual function. there is no pure keyword in C++. |
|
| 84. |
Pick the incorrect statement about Character-Array.(a) Character-Array can be terminated by a null character(‘’)(b) Character-Array has a static size(c) Character-Array has a dynamic size(d) Character-Array has a threat of array-decay |
|
Answer» Right choice is (c) Character-Array has a dynamic size Easy explanation - As Character-Array is an array, its size should be defined during its declaration hence the size of Character-Array is static. A Character-Array is not necessarily to be terminated by a null character. Also, it has a threat of array-decay. |
|
| 85. |
Which header file is used to declare the complex number?(a) complexnum(b) complex(c) complex number(d) complexarg |
|
Answer» The correct choice is (b) complex Easy explanation - |
|
| 86. |
How many real types are there in complex numbers?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» The correct answer is (c) 3 To explain I would say: There are three real types in complex numbers. They are float complex, double complex, long double complex. |
|
| 87. |
Pick out the correct statement.(a) Pre Increment is faster than post-increment(b) post-increment is faster than Pre Increment(c) pre increment is slower than post-increment(d) pre decrement is slower than post-increment |
|
Answer» Correct option is (a) Pre Increment is faster than post-increment To explain I would say: Because Pre Increment take one-byte instruction & post increment takes two-byte instruction. |
|
| 88. |
Pick out the compound assignment statement.(a) a = a – 5(b) a = a / b(c) a -= 5(d) a = a + 5 |
|
Answer» The correct answer is (c) a -= 5 To explain: When we want to modify the value of a variable by performing an operation on the value currently stored, We will use compound assignment statement. In this option, a -=5 is equal to a = a-5. |
|
| 89. |
What are the essential operators in c++?(a) +(b) |(c) |
|
Answer» Right answer is (d) All of the mentioned Easy explanation - Essential operators in c++ are +, |, <=. |
|
| 90. |
Which other keywords are also used to declare the class other than class?(a) struct(b) union(c) object(d) both struct & union |
|
Answer» Correct option is (d) both struct & union Easiest explanation - Struct and union take the same definition of class but differs in the access techniques. |
|
| 91. |
Which category of data type a class belongs to?(a) Fundamental data type(b) Derived data type(c) User defined derived data type(d) Atomic data type |
|
Answer» The correct choice is (c) User defined derived data type The explanation: Fundamental/Atomic data type includes int, char, float, double and void. Derived data type includes arrays, pointers, references, function and constants. User defined derived data type includes class, structure, union and enumeration. |
|
| 92. |
How many types of representation are in the string?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» Correct option is (b) 2 The best I can explain: C++ provides the following two types of string representations. They are C-style character string and string class type with Standard C++. |
|
| 93. |
The data members and functions of a class in C++ are by default ____________(a) protected(b) private(c) public(d) public & protected |
|
Answer» The correct option is (b) private To explain: By default all the data members and member functions of class are private. |
|
| 94. |
What does a mutable member of a class mean?(a) A member that can never be changed(b) A member that can be updated only if it not a member of constant object(c) A member that can be updated even if it a member of constant object(d) A member that is global throughout the class |
|
Answer» Correct answer is (c) A member that can be updated even if it a member of constant object For explanation: Mutable members are those which can be updated even if it a member of a constant object. You can change their value even from a constant member function of that class. |
|
| 95. |
subscript operator is used to access which elements?(a) string(b) char(c) array(d) float |
|
Answer» Correct answer is (c) array The best explanation: To access any element of an array we use following syntax array[i], where i is called subscript representing the ith element of an array, whereas no such cases in char and strings. |
|
| 96. |
Which operator a pointer object of a class uses to access its data members and member functions?(a) .(b) ->(c) :(d) :: |
|
Answer» Correct option is (b) -> For explanation: ->(arrow operator) is used by a pointer object to access members of its class. |
|
| 97. |
How many specifiers are present in access specifiers in class?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» The correct choice is (c) 3 Explanation: There are three types of access specifiers. They are public, protected and private. |
|
| 98. |
Which rule will not affect the friend function?(a) private and protected members of a class cannot be accessed from outside(b) private and protected member can be accessed anywhere(c) protected member can be accessed anywhere(d) private member can be accessed anywhere |
|
Answer» Right option is (a) private and protected members of a class cannot be accessed from outside To explain I would say: Friend is used to access private and protected members of a class from outside the same class. |
|
| 99. |
How to stop your program from eating so much ram?(a) Find a way to work with the data one at a time(b) Declare it in program memory, instead of on the stack(c) Use the hard drive, instead of RAM(d) All of the mentioned |
|
Answer» Right answer is (d) All of the mentioned Explanation: Some of the ways to stop the program by consuming more ram. They are i) Find a way to work with the data one at a time ii) Declare it in program memory, instead of on the stack iii) Use the hard drive, instead of RAM |
|
| 100. |
How to access the object in the class?(a) scope resolution operator(b) ternary operator(c) direct member access operator(d) resolution operator |
|
Answer» The correct option is (c) direct member access operator The best explanation: Objects in the method can be accessed using direct member access operator which is (.). |
|