Alternatives to If (Unless, Provided That, As Long As, In Case)

Alternatives to If (Unless, Provided That, As Long As, In Case) — Bài Tập 5

/ 10

Alternatives to If (Unless, Provided That, As Long As, In Case) — Bài Tập 5

Luyện tập ngữ pháp tiếng Anh chủ đề Alternatives to If (Unless, Provided That, As Long As, In Case) qua 10 câu hỏi trắc nghiệm. Trả lời đúng ít nhất 70% để hoàn thành bài.

Other conditional conjunctions: unless (if not), provided that, as long as (only if), in case (as a precaution).

B2 · Upper Intermediate TOEIC 605–780 IELTS 5.5–6.5 Clauses & Conditionals
10 câu hỏi Điểm qua: 70% Bài 5

Hướng dẫn làm bài

  • Đọc kỹ từng câu hỏi và chọn đáp án đúng nhất.
  • Bài thi không giới hạn thời gian — bạn có thể làm theo tốc độ của mình.
  • Nhấn Nộp bài khi đã hoàn thành để xem kết quả và giải thích chi tiết.

Login to save your result

You can take this test without logging in, but your result won't be saved. Login to track your progress.

  1. 1

    You are refactoring a system where a complex `if-else if` structure is used to determine the behavior of an object based on its components (e.g., a `Graphic` object can be a `Circle`, `Square`, or a `Group` of graphics). Which design pattern would allow you to treat individual objects and compositions of objects uniformly, thus avoiding conditional logic for handling different types?

  2. 2

    You are building a system that needs to map UI component names to their corresponding React/Vue/Angular components (e.g., 'Button' to `<ButtonComponent>`, 'Input' to `<InputComponent>`). Which data structure is most efficient for replacing a large `if-else if` or `switch` statement for dynamic component rendering?

  3. 3

    When refactoring a series of `if-else if` statements that check for different types of objects and perform type-specific actions, which design principle or pattern is often a superior alternative?

  4. 4

    Consider a scenario where you need to access a property of an object, but the object itself or an intermediate property might be null or undefined. Which operator provides a safe way to access nested properties without explicit null checks?

  5. 5

    What is the value of `discount` in `const discount = (isPremium) ? 0.15 : 0.05;` if `isPremium` is `true`?

  6. 6

    In many languages, what is the primary keyword used to define a block of code that executes based on the value of an expression in a switch statement?

  7. 7

    A payment processing system needs to support various payment methods (e.g., Credit Card, PayPal, Bank Transfer). Each method has a distinct set of steps for authorization and capture. Which design pattern would best allow you to add new payment methods without modifying the core payment processing logic, replacing a large `if-else if` structure?

  8. 8

    Which of the following is a valid way to use a `switch` statement with an `enum` type?

  9. 9

    In a `switch` statement, if a `case` block does not have a `break` statement, what happens?

  10. 10

    If `user.isAdmin` is false, what is the outcome of `user.isAdmin && showAdminPanel();`?