Activity 1.6.1.
Consider the following Java function. What happens when the function is called with the given inputs
print(2, 0, 0);?
public static void print(int x, int y, int z) {
if (x > 10 || x / y > 10 || z > 10) {
System.out.println("Condition met");
}
System.out.println("End of program");
}
-
The code first prints "Condition met" and then prints "End of program"
- Think about what you learned for short circuit evaluation from the video
- The code only prints "End of program"
- Think about what you learned for short circuit evaluation from the video
-
The code throws an error for division by zero
- The first condition is false, therefore the program checks the second condition and throws an exception.
