Ask Question
15 May, 07:59

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

+4
Answers (1)
  1. 15 May, 09:11
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers