Java Reference
In-Depth Information
{
System.out.print(x + " ");
exercise(x + 1);
}
}
What is the output of the following statements?
c. exercise(10);
d. exercise(-5);
10. Consider the following recursive function:
public static void recFun( int x)
{
exercise(0);
a.
exercise(5);
b.
if (x > 10)
{
recFun(x / 10);
System.out.println(x % 10);
}
else
System.out.println(x);
}
What is the output of the following statements?
a.
recFun(258);
recFun(36);
c.
recFun(7);
recFun(-85);
b.
d.
11. Consider the following recursive function:
public static void recFun( int u)
{
if (u == 1)
System.out.print("Stop! ");
else
{
System.out.print("Go ");
recFun(u - 1);;
}
}
What is the output, if any, of the following statements?
a.
1
3
recFun(7); b.
recFun(-6);
recFun(3);
c.
Search WWH ::




Custom Search