Question: Determine the output of the following program by constructing a box trace: public class ThisExample { public static void main(String[] args) { System. out .println(

Determine the output of the following program by constructing a box trace:

public class ThisExample {

public static void main(String[] args) {

System.out.println(getValue(1, 7, 7));

}

public static int getValue(int a, int b, int n)

{

int returnValue;

System.out.println("Enter: a = " + a + " b = " + b);

int c = (a + b)/2;

if (c * c <= n)

returnValue = c;

else

returnValue = getValue(a, c-1, n);

System.out.println("Leave: a = " + a + " b = " + b);

return returnValue;

}

}

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!