🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Type Casting in C++: all 10 questions

Quiz: Type Casting in C++ · Question 3 of 10

What does dynamiccast<Manager (p) return if p points to an Engineer object (not a Manager)?

What does dynamic_cast<Manager *>(p) return if p points to an Engineer object (not a Manager)?

  1. A.A Manager pointer with random data
  2. B.It throws std::bad_cast
  3. C.nullptr
  4. D.A compile error
Answer & explanation

Correct answer: nullptr

For pointers, a failed dynamic_cast returns nullptr; for references it throws bad_cast.

Can you get the rest right without peeking?

Take the timed Quiz: Type Casting in C++ quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →