Match List-I and List-II Choose the correct answer from the options given below:

2022

Match List-I and List-II

image.png

Choose the correct answer from the options given below:

Answer: B. A-III, B-I, C-II, D-IVCorrect matching: A → to use templates; B → to use class hierarchy; C → improved run-time efficiency; D → to use explicit casting. A (If implementations…

  1. A.

    A-I, B-II, C-IV, D-III

  2. B.

    A-III, B-I, C-II, D-IV

  3. C.

    A-I, B-III, C-II, D-IV

  4. D.

    A-II, B-I, C-III, D-IV

Attempted by 43 students.

Show answer & explanation

Correct answer: B

Correct matching: A → to use templates; B → to use class hierarchy; C → improved run-time efficiency; D → to use explicit casting.

  • A (If implementations differ only through a parameter): Use templates because they parameterize code at compile time and avoid creating separate class hierarchies for each parameter variant.

  • B (If actual object types cannot be known at compile time): Use a class hierarchy with polymorphism (inheritance and virtual functions) to select behavior at run time.

  • C (If inline operations are essential and templates are used): This yields improved run-time efficiency because templates enable compile-time expansion and inlining, removing virtual-call overhead.

  • D (To gain access to differing derived instances through a base): Use explicit casting (for example dynamic_cast or static_cast as appropriate) to access derived-specific members when you have a base-class reference or pointer.

Therefore the correct answer is the matching that pairs A with templates, B with class hierarchy, C with improved run-time efficiency, and D with explicit casting.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor Computer Science Paper 2

Loading lesson…