To refactor sequential if statements, when they have the same body, we can always conjoin their conditions using ||.
No! Not always
We can conjoin the conditions of sequential if statements with the same body using || when those conditions are exclusive.
Correct!
Sequential if statements with mutually exclusive conditions, can be refactored to use else if structure and when their body is also the same, they can be conjoined using ||.
Correct!
if we have sequential if statements where each statement prints a message, and conditions are NOT mutually exclusive, multiple if conditions may evaluate to true in one run.
We want the canPlayOutside() function to take a String parameter, weather, and print some messages. If the weather equals "sunny" the function prints, "You can play outside!". Similarly, when the weather is "cloudy" the function prints "You can play outside!". However, if the weather is "windy", it prints, "you should play inside!". To compare two String values, use equals() method.
public static void canPlayOutside(String weather) {
if (.........blank1...............) {
System.out.println(“You can play outside!”);
} .......blank2....... {
System.out.println(“You should play inside!”);
}
}