1. What output will be produced by the following code?
public class Demo
{
public static void main(String[] args)
System.out.println(“The output is:”);
foo(564);
System.out.println();
}
public static void foo(int number)
if (number > 0)
foo(number / 3);
System.out.print(number % 3);
2. What output will be produced by the following code?
bar(123456);
public static void bar(int number)
int d = number % 10;
boolean even = (number / 10) % 2 == 0;
bar(number / 10);
if (even)
System.out.print(d / 2 + 4);
else
System.out.print(d / 2 + 3);
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here