Explore topic-wise MCQs in Object Oriented Programming.

This section includes 19 Mcqs, each offering curated multiple-choice questions to sharpen your Object Oriented Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

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();
2.

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
3.

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
4.

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
5.

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
6.

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
7.

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
8.

Which casting among the following is allowed for the code given below?

A. Casting 1
B. Casting 2
C. casting 1 and casting 2
D. casting 1 nor casting 2View Answer
Answer» C. casting 1 and casting 2
9.

Upcasting and downcasting objects are the same as casting primitive types.

A. True
B. False
Answer» C.
10.

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
11.

Which among the following is the 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
12.

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
13.

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
14.

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
15.

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
16.

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» C. Always allowed for private inheritance
17.

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» B. Class C object can be upcasted to object of class A only
18.

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» E.
19.

Casting ?

A. Casting 2
B. casting 1 and casting 2
C. casting 1 nor casting 2
Answer» D.