Object Oriented Programming MCQs

Page No. 83

What is upcasting?


aCasting subtype to supertype


bCasting super type to subtype


cCasting subtype to super type and vice versa


dCasting anytype to any other type



Why is downcasting possible in any language?


aBecause inheritance follows has-a relationship


bBecause inheritance follows is-a relationship


cBecause inheritance doesn’t follow any relationship


dBecause inheritance is not involved in casting



When is the downcasting used?


aTo separate inherited class from base class


bTo write a more complex code


cTo compare two objects


d To disable one class in inheritance



What happens when downcasting is done but not explicitly defined in syntax?


a Compile time error


bRuntime error


cCode write time error


dConversion error


View Answer Compile time error

Which way the downcasting is possible with respect to inheritance?


aUpward the inheritance order


bDownward the inheritance order


cDownward the inheritance order


dOrder of inheritance doesn’t matter



Java supports direct downcasting


aTrue


bFalse


cA & B


d None of the above


View Answer False

How to prevent the ClassCastExceptions?


aBy using instanceof


bBy using is-a check


cBy using arrow operator with check function


dBy checking type of conversion


View Answer By using instanceof

Which is the exception handler for the exceptions of downcasting?


aCastException


bClassCastingExeption


cClassCasting


dClassCastException


View Answer ClassCastException

Which is the proper syntax of dynamic_cast?


adynamic_cast(object)


bdynamic_cast new (object)


cdynamic_cast(object)


ddynamic_cast(object)


View Answer dynamic_cast(object)

If dynamic_cast fails, which value is returned?


a void


bnull


cvoid pointer


dnull pointer


View Answer null pointer

Goto Page No.

Page 83 of 93

Alphabetical MCQs Categories

Here below You find all kind of categories of MCQs in alphabetical order.


"Comprehensive Collection of MCQs: Alphabetically Organized by Subject"

"Discover an extensive collection of multiple-choice questions (MCQs) neatly categorized by subject from A to Z. This resource is designed for anyone eager to explore various topics in a straightforward and organized manner. Whether you're a student preparing for exams, an educator seeking supplementary materials, or simply curious about different subjects, this compilation offers a convenient way to learn and assess your knowledge. With questions arranged alphabetically, navigation is effortless, allowing you to delve into subjects of interest at your own pace. Engage, learn, and expand your understanding with this accessible and comprehensive repository of MCQs!"


BolPakistan

bolpakistan.com.pk includes Job Mcqs and Pak Mcqs is the Top Largest Mcqs Forum in World, in which you can read Mcqs of All Subjects, PPSC test preparation, FPSC, NTS and PPSC PAST PAPERS, PPSC PAST MCQS. A Collection of Repeated MCQs for JOBs seekers.

Copyright © 2024, Designed & Developed by BolPakistan