Quiz · Methods · lesson 2 of 8
Quiz — return not on every path
What happens when the program is compiled and run?
public class Main {
static int sign(int x) {
if (x > 0) {
return 1;
} else if (x < 0) {
return -1;
}
}
public static void main(String[] args) {
System.out.println(sign(5));
}
}