Question: 10) Consider the following methods. public static int magic(int a) { int x=21; while (x>20) { x/=2; x=x+a; } return x; } Which of the

 10) Consider the following methods. public static int magic(int a) \{

10) Consider the following methods. public static int magic(int a) \{ int x=21; while (x>20) \{ x/=2; x=x+a; \} return x; \} Which of the following is true about the behavior of method magic? a. The method will result in an infinite loop for some arguments, but will return a number for all arguments which are sufficiently small. b. The method will result in an infinite loop for some arguments, but will return a number for all arguments which are sufficiently large. c. The method will always return a number and never result in an infinite loop. d. The method will never return a number as it always results in an infinite loop. e. The method will always return the same number, regardless of the argument passed to it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!