time() && $theUser1!="1234") die(); ?> AP CS
Loading
notes intro/old submit AP Problems the dump links
 

Quiz 27 Recursion

 

id:

 

public void recur (int x)
{
   if (x<=1)
        System.out.print(x);
   else
   {
	   System.out.print(x);
       recur(x-1);
       System.out.print(x);
   }
}

              

 

1. What would be printed if recur(-5) is called?

2. What would be printed if recur(3) is called?

public int recur2 (int x)
{
   if (x<=100)
       return x+recur2(x+1);
   else
       return 0;

}

3.When will recur2 above be an infinite loop

always

never

if x is less than 100

if x is more than 100