🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Type Casting in C++: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. Which cast should you use to convert an int to a double?
  3. Q3. What does dynamiccast<Manager (p) return if p points to an Engineer object (not a Manager)?
  4. Q4. Why does dynamiccast need the base class to have at least one virtual function?
  5. Q5. What does this print? (code)
  6. Q6. What is the legitimate use of constcast?
  7. Q7. Why are C-style casts like (int)x discouraged in C++?
  8. Q8. What does an upcast mean?
  9. Q9. What does the explicit keyword on a single-argument constructor do?
  10. Q10. Why does the byte-printing reinterpretcast example print different results on different machines?