Ask Question

Consider the method total below:

public static int total (int result, int a, int b) { if (a = = 0) { if (b = = 0) { return result * 2; } return result / 2; } else { return result * 3; }}

The assignment statementx = total (1, 1, 1); must result in:A. x being assigned the value 3 B. x being assigned the value 7C. x being assigned the value 5D. x being assigned the value 2E. x being assigned the value 0

+3
Answers (1)
  1. 19 November, 22:02
    0
    When you look at the assignment "x = total (1, 1, 1); ", you can see that result, a and b all refers to 1. Then, you need to go to the function and check the conditions. The first condition is "if (a = = 0) ", it is not true because a is assigned to 1. Since that is not true, you need to go to the else part "else { return result * 3". That means the result of this function is going to give us 3 (because result variable equals to 1 initially). That is why x is going to be assigned as 3.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Consider the method total below: public static int total (int result, int a, int b) { if (a = = 0) { if (b = = 0) { return result * 2; } ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers