public static int max(int a, int b) {
if (a > b) {
return a;
}
// line 4
}What must be added at line 4 to make the method compile and work?
- Acheck_circle
return b;
- B
Nothing; the code compiles as is
- C
break;
- D
return 0;
Explanation
Java requires every code path of a non-void method to return a value. When a <= b, no return executes, so the method must return b.