MCQOPTIONS
Bookmark
Saved Bookmarks
→
Object Oriented Programming
→
Inbuilt Classes in Object Oriented Programming
→
If dynamic_cast fails, which value is returned?..
1.
If dynamic_cast fails, which value is returned?
A.
void
B.
null
C.
void pointer
D.
null pointer
Answer» E.
Show Answer
Discussion
No Comment Found
Post Comment
Related MCQs
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: cExplanation: The dynamic_cast is the name of the operator, which is followed by the new type in which the object have to be converted. Then the object name is given. This object name is then used after the type conversion.9. Which is the exception handler for the exceptions of downcasting?a) CastExceptionb) ClassCastingExeptionc) ClassCastingd) ClassCastExceptionAnswer: dExplanation: The exception handler for the exceptions produced during the downcasting exception. This handler can be called during runtime to handle any exception thrown.advertisement/**/ var adpushup = adpushup || {}; adpushup.que = adpushup.que || []; adpushup.que.push(function() { adpushup.triggerAd("90f55663-effd-4105-b1e7-29d86b526544"); });/**/10. How to prevent the ClassCastExceptions?a) By using instanceofb) By using is-a checkc) By using arrow operator with check functiond) By checking type of conversionAnswer: aExplanation: The instanceof operator can be used to check the compatibility of the conversion. This has to be done to check whether the casting would be safe or not.11. Java supports direct downcasting.a) Trueb) FalseAnswer: bExplanation: The downcasting is not possible in java directly. This has to be done explicitly. The downcasting is not safe but can be checked for safe casting using instanceof function.12. Which way the downcasting is possible with respect to inheritance?a) Upward the inheritance orderb) Downward the inheritance orderc) Either upward or downward the inheritance orderd) Order of inheritance doesn’t matterAnswer: bExplanation: The downcasting is always downward the inheritance order. Since the base class object have to be casted into derived class type. This is a basic definition of downcasting.13. What happens when downcasting is done but not explicitly defined in syntax?a) Compile time errorb) Runtime errorc) Code write time errord) Conversion errorAnswer: aExplanation: The implicit downcasting is not possible. If tried, the compiler produces an error. Since the compiler doesn’t allow coasting to a type that is not compatible.14. When is the downcasting used?a) To separate inherited class from base classb) To write a more complex codec) To compare two objectsd) To disable one class in inheritanceAnswer: cExplanation: The downcasting can be used whenever there is a need to compare one object to another. Equals() function can be used to compare whether the objects were of same age. We can use getClass() function too.15. Why is downcasting possible in any language?
If dynamic_cast fails, which value is returned?
What does dynamic_cast return after successful type casting?
What should be used for safe downcast?
Downcasting ____________________
Downcasting is _______________________
Which among the following is a mandatory condition for downcasting?
What is downcasting?
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply