public class Tester {
public int sign(int n) {
if (n > 0) return 1;
if (n < 0) return -1;
return 0;
}
}
// ...
Tester t = new Tester();
System.out.println(t.sign(0));What is printed?
- A
Compile-time error
- B
-1
- C
1
- Dcheck_circle
0
Explanation
n is 0, so neither if branch returns; the final return 0 executes.