

MCQOPTIONS
Saved Bookmarks
This section includes 916 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
101. |
Which type of value is resulted from the delete operator? |
A. | void |
B. | void pointer |
C. | null pointer |
D. | null |
Answer» B. void pointer | |
102. |
Does delete return any value? |
A. | Yes, positive value |
B. | Yes, negative value |
C. | Yes, zero value |
D. | No |
Answer» E. | |
103. |
If an object is allocated using new operator ____________ |
A. | It should be deleted using delete operator |
B. | It can’t be deleted using delete operator |
C. | It may or may not be deleted using delete operator |
D. | The delete operator is not applicable |
Answer» B. It can’t be deleted using delete operator | |
104. |
If an object is allocated using new operator ___________ |
A. | It should be deleted using delete operator |
B. | It can’t be deleted using delete operator |
C. | It may or may not be deleted using delete operator |
D. | The delete operator is not applicable |
Answer» B. It can’t be deleted using delete operator | |
105. |
What is delete operator? |
A. | Deallocates a block of memory |
B. | Deallocates whole program memory |
C. | Deallocates only primitive data memory |
D. | Deallocates all the data reserved for a class |
Answer» B. Deallocates whole program memory | |
106. |
How does compiler convert “::operator new” implicitly? |
A. | ::operator new( sizeof( type ) ) |
B. | ::operator new( sizeof( ) ) |
C. | new operator :: type sizeof( type ) |
D. | new sizeof( type ) operator |
Answer» B. ::operator new( sizeof( ) ) | |
107. |
If new operator is defined for a class and still global new operator have to be used, which operator should be used with the keyword new? |
A. | Colon |
B. | Arrow |
C. | Dot |
D. | Scope resolution |
Answer» E. | |
108. |
The new operator _________________ |
A. | Invokes function operator new |
B. | Doesn’t invoke function operator new |
C. | Invokes function operator only if required |
D. | Can’t invoke function operator new implicitly |
Answer» B. Doesn’t invoke function operator new | |
109. |
The objects allocated using new operator ________________ |
A. | Are destroyed when they go out of scope |
B. | Are not destroyed even if they go out of scope |
C. | Are destroyed anytime |
D. | Are not destroyed throughout the program execution |
Answer» C. Are destroyed anytime | |
110. |
Initializers __________________ |
A. | Are used for specifying arrays |
B. | Are used to defined multidimensional arrays |
C. | Can’t be specified for arrays |
D. | Can’t be specified for any data |
Answer» D. Can’t be specified for any data | |
111. |
Which among the following is added in grammar of new operator? |
A. | Finalize |
B. | Arg |
C. | Initializer |
D. | Allocator |
Answer» D. Allocator | |
112. |
The new operator _____________ |
A. | Can allocate reference types too |
B. | Doesn’t allocate reference types |
C. | Can allocate reference to objects |
D. | Doesn’t allocate any data |
Answer» C. Can allocate reference to objects | |
113. |
For declaring data by using new operator ____________________ |
A. | Type name can’t contain const |
B. | Type name can’t contain volatile |
C. | Type name can’t contain class declarations |
D. | Type name can’t contain const, volatile, class declaration or enumerations |
Answer» E. | |
114. |
Which among the following is correct syntax to declare a 2D array using new operator? |
A. | char (*pchar)[10] = new char[][10]; |
B. | char (pchar) = new char[][10]; |
C. | char (*char) = new char[10][]; |
D. | char (*char)[][10]= new char; |
Answer» B. char (pchar) = new char[][10]; | |
115. |
In C++, if new operator is used, when is the constructor called? |
A. | Before the allocation of memory |
B. | After the allocation of memory |
C. | Constructor is called to allocate memory |
D. | Depends on code |
Answer» C. Constructor is called to allocate memory | |
116. |
If new throws an error, which function can be called to write a custom exception handler? |
A. | _set_handler |
B. | _new_handler |
C. | _handler_setter |
D. | _set_new_handler |
Answer» E. | |
117. |
What happens when new fails? |
A. | Returns zero always |
B. | Throws an exception always |
C. | Either throws an exception or returns zero |
D. | Terminates the program |
Answer» D. Terminates the program | |
118. |
Microsoft C++ Components extensions support new keyword to _____________ |
A. | Modify a vtable |
B. | Replace a vtable slot entry |
C. | Add new vtable slot entries |
D. | Rearrange vtable slot entries |
Answer» D. Rearrange vtable slot entries | |
119. |
What is new operator? |
A. | Allocates memory for an object or array |
B. | Allocates memory for an object or array and returns a particular pointer |
C. | Used as return type when an object is created |
D. | Used to declare any new thing in a program |
Answer» C. Used as return type when an object is created | |
120. |
Why is downcasting possible in any language? |
A. | Because inheritance follows has-a relationship |
B. | Because inheritance follows is-a relationship |
C. | Because inheritance doesn’t follow any relationship |
D. | Because inheritance is not involved in casting |
Answer» C. Because inheritance doesn’t follow any relationship | |
121. |
When is downcating used? |
A. | To separate inherited class from base class |
B. | To write a more complex code |
C. | To compare two objects |
D. | To disable one class in inheritance |
Answer» D. To disable one class in inheritance | |
122. |
What happens when downcasting is done but not explicitly defined in syntax? |
A. | Compile time error |
B. | Runtime error |
C. | Code write time error |
D. | Conversion error |
Answer» B. Runtime error | |
123. |
Which way the downcasting is possible with respect to inheritance? |
A. | Upward the inheritance order |
B. | Downward the inheritance order |
C. | Either upward or downward the inheritance order |
D. | Order of inheritance doesn’t matter |
Answer» C. Either upward or downward the inheritance order | |
124. |
Java supports direct downcasting. |
A. | True |
B. | False |
Answer» C. | |
125. |
How to prevent the ClassCastExceptions? |
A. | By using instanceof |
B. | By using is-a check |
C. | By using arrow operator with check function |
D. | By checking type of conversion |
Answer» B. By using is-a check | |
126. |
Which is the exception handler for the exceptions of downcasting? |
A. | CastException |
B. | ClassCastingExeption |
C. | ClassCasting |
D. | ClassCastException |
Answer» E. | |
127. |
Which is the proper syntax of dynamic_cast? |
A. | dynamic_cast(object) |
B. | dynamic_cast new (object) |
C. | dynamic_cast(object) |
D. | dynamic_cast(object) |
Answer» D. dynamic_cast(object) | |
128. |
If dynamic_cast fails, which value is returned? |
A. | void |
B. | null |
C. | void pointer |
D. | null pointer |
Answer» E. | |
129. |
What does dynamic_cast return after successful type casting? |
A. | Address of object which is converted |
B. | Address of object that is used for conversion |
C. | Address of object that is mentioned in the syntax |
D. | Doesn’t return any address |
Answer» B. Address of object that is used for conversion | |
130. |
What should be used for safe downcast? |
A. | Static cast |
B. | Dynamic cast |
C. | Manual cast |
D. | Implicit cast |
Answer» C. Manual cast | |
131. |
Downcasting ____________________ |
A. | Can result in unexpected results |
B. | Can’t result in unexpected result |
C. | Can result only in out of memory error |
D. | Can’t result in any error |
Answer» B. Can’t result in unexpected result | |
132. |
Downcasting is _______________________ |
A. | Always safe |
B. | Never safe |
C. | Safe sometimes |
D. | Safe, depending on code |
Answer» C. Safe sometimes | |
133. |
Which among the following is a mandatory condition for downcasting? |
A. | It must not be done explicitly |
B. | It must be done implicitly |
C. | It must be done explicitly |
D. | It can’t be done explicitly |
Answer» D. It can’t be done explicitly | |
134. |
What is downcasting? |
A. | Casting subtype to supertype |
B. | Casting supertype to subtype |
C. | Casting subtype to supertype and vice versa |
D. | Casting anytype to any other type |
Answer» C. Casting subtype to supertype and vice versa | |
135. |
If two classes are defined “Parent” and “Child” then which is the correct type upcast syntax in C++? |
A. | Parent *p=child; |
B. | Parent *p=*child; |
C. | Parent *p=&child; |
D. | Parent *p=Child(); |
Answer» D. Parent *p=Child(); | |
136. |
When are the object type known for upcasting the objects? |
A. | Compile time |
B. | Runtime |
C. | Source code build time |
D. | Doesn’t apply to objects directly |
Answer» C. Source code build time | |
137. |
When are the pointer types known for upcasting the objects? |
A. | Compile time |
B. | Runtime |
C. | Source code build time |
D. | Doesn’t apply to pointer types |
Answer» B. Runtime | |
138. |
Which concept is needed because of implicit type casting use? |
A. | Static binding |
B. | Dynamic binding |
C. | Compile time binding |
D. | Source code binding |
Answer» C. Compile time binding | |
139. |
Upcasting is _____________________ without an explicit type cast. |
A. | Always allowed for public inheritance |
B. | Always allowed for protected inheritance |
C. | Always allowed for private inheritance |
D. | Not allowed |
Answer» B. Always allowed for protected inheritance | |
140. |
If class C inherits class B and class B inherits class A ________________ |
A. | Class C object can be upcasted to object of class B only |
B. | Class C object can be upcasted to object of class A only |
C. | Class C object can be upcasted to object of either class A or B |
D. | Class C object can’t be upcasted |
Answer» D. Class C object can’t be upcasted | |
141. |
If multiple inheritance is implemented, which upcasting will be correct? |
A. | Upcast to first base class listed in inheritance |
B. | Upcast to send base class listed in inheritance |
C. | Upcast to any base class |
D. | Upcast is not possible |
Answer» D. Upcast is not possible | |
142. |
Upcasting and downcasting objects is same as casting primitive types. |
A. | True |
B. | False |
Answer» C. | |
143. |
Which property is shown most when upcasting is used? |
A. | Code reusability |
B. | Code efficiency |
C. | Complex code simple syntax |
D. | Encapsulation |
Answer» D. Encapsulation | |
144. |
Which among the following is best situation to use upcasting? |
A. | For general code dealing with only subtype |
B. | For general code dealing with only supertype |
C. | For general code dealing with both the supertype and subtype |
D. | For writing a rigid code with respect to subtype |
Answer» C. For general code dealing with both the supertype and subtype | |
145. |
Which among the following is safe? |
A. | Upcasting |
B. | Downcasting |
C. | Both upcasting and downcasting |
D. | If upcasting is safe then downcasting is not, and vice versa |
Answer» B. Downcasting | |
146. |
Which among the following is true for upcasting in inheritance? |
A. | Downward to the inheritance tree |
B. | Upward to the inheritance tree |
C. | Either upward or downward |
D. | Doesn’t apply on inheritance |
Answer» C. Either upward or downward | |
147. |
What is upcasting? |
A. | Casting subtype to supertype |
B. | Casting super type to subtype |
C. | Casting subtype to super type and vice versa |
D. | Casting anytype to any other type |
Answer» B. Casting super type to subtype | |
148. |
Which is a good alternative instead of having one zero argument constructor and one single argument constructor with default argument? |
A. | No constructor defined |
B. | One default value constructor |
C. | Defining the default constructor |
D. | Using one constructor with two arguments |
Answer» C. Defining the default constructor | |
149. |
Which is the correct statement for default constructors? |
A. | The constructors with all the default arguments |
B. | The constructors with all the null and zero values |
C. | The constructors which can’t be defined by programmer |
D. | The constructors with zero arguments |
Answer» E. | |
150. |
If there is a constructor with all the default arguments and arguments are not passed then _________________ |
A. | The default values given will not be used |
B. | Then all the null values will be used |
C. | Then all the default values given will be used |
D. | Then compiler will produce an error |
Answer» D. Then compiler will produce an error | |