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...


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?


public class Demo


{


public static void main(String[] args)


{


System.out.println(“The output is:”);


bar(123456);


System.out.println();


}


public static void bar(int number)


{


if (number > 0)


{


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);


}


}


}



Nov 13, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here