Courseiva
hardMultiple ChoiceObjective-mapped

200-901 Practice Question: During a code review, a developer notices that a…

During a code review, a developer notices that a function has multiple nested if-else statements. Which refactoring technique would improve maintainability?

⚠ Common exam trap

Cisco often tests the distinction between 'improving readability' (e.g., Extract Method, Decompose Conditional) and 'fundamentally changing the design to eliminate conditionals' (Replace Conditional with Polymorphism), leading candidates to choose a refactoring that only reorganizes code rather than removing the nested logic.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Replace conditional with polymorphism

Replacing complex conditionals with polymorphism aligns with the Open/Closed Principle, allowing each subclass to handle its own behavior without modifying existing code. This refactoring technique directly addresses the maintainability issue of deeply nested if-else statements by delegating decision logic to polymorphic method dispatch, which is a core object-oriented design pattern tested in the 200-901 exam.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Introduce parameter object

    Why it's wrong here

    This refactoring addresses long parameter lists, not conditional complexity.

  • Decompose conditional

    Why it's wrong here

    Decompose conditional breaks a complex conditional into separate methods, but it still retains the conditional structure.

  • Replace conditional with polymorphism

    Why this is correct

    Polymorphism allows each subclass to implement its own behavior, eliminating the need for complex conditionals.

  • Extract method

    Why it's wrong here

    Extract method reduces duplication but does not remove the conditional logic itself.

About these practice questions

This 200-901 question is part of Courseiva's 989-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.