QuestionQ191

Using Operators and Decision Constructs

Given the following:

Question Image

Which code fragment can be used to replace the if block?

  • A
  • B
  • C
  • D
Explanation

A nested conditional expression can assign "Walter" when stuff.equals("TV") is true; otherwise, it evaluates stuff.equals("Movie") to choose "White" or "No Result". This preserves the same conditions and assignments as the original control flow.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!