Consider the following recursive method. public static void…
Consider the following recursive method. public static void stars(int num) { if (num == 1) { return; } stars(num – 1); for (int i = 0; i < num; i++) { System.out.print("*"); } System.out.println(); } What is printed as a result of the method call stars(5) ? A ***** B ** *** **** ***** C * ** *** **** ***** D ***** **** *** ** E ***** **** *** ** *
Read DetailsThe bark method below is intended to print the string “woof”…
The bark method below is intended to print the string “woof” a total of num times. public static void bark(int num) { if (num > 0) { System.out.println(“woof”); /* missing code */ } } Which of the following can be used to replace /* missing code */ so that the call bark(5) will cause “woof” to be printed five times?
Read DetailsConsider the following recursive method. public static Strin…
Consider the following recursive method. public static String recur(int val) { String dig = “” + (val % 3); if (val / 3 > 0) return dig + recur(val / 3); return dig; } What is printed as a result of executing the following statement? System.out.println(recur(32));
Read Details