Activity 1.25.1.
canPlayoutside("rainy")
canPlayoutside("sunny")
canPlayoutside("cloudy")
public static boolean canPlayoutside(String weather) { if (weather.equals("rainy")) { return false; } return true; }
- Correct!
public static boolean canPlayoutside(String weather) { if (!weather.equals("rainy")) { return true; } return false; }
- Correct!
public static boolean canPlayoutside(String weather) { return !weather.equals("rainy"); }
- Correct!
Look at the first code block. Which of the following options have the same functionality as it (i.e., they produce the same output for the same inputs)? You can check the Hint for some input examples.
public static boolean canPlayoutside(String weather) {
if (weather.equals("rainy")) {
return false;
} else {
return true;
}
}
Hint.
You can use the following test cases to compare the code blocks’ functionality.
Select all that apply.