CJCoding With Joseph
15free / daySign inCreate account
Back to Multiple Choice Quiz

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics

Sign Method Output

Java quiz · Question 10
mediumMethods

What does this method return when called with getSign(-5)?

Code

1public static int getSign(int num) {
2 if (num > 0) {
3 return 1;
4 } else if (num < 0) {
5 return -1;
6 } else {
7 return 0;
8 }
9}