Ask Question
17 April, 12:09

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

+5
Answers (1)
  1. 17 April, 12:20
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers