16 If the method below was called with the value 4 (for example print(4)), how many times would “Hello World" be printed
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
16 If the method below was called with the value 4 (for example print(4)), how many times would “Hello World" be printed
16 If the method below was called with the value 4 (for example print(4)), how many times would “Hello World" be printed out? 14 public static void print(int num) { 15 if(num == 1){ //simply "give" control back A.) 4 17 return; B.) 3 18 }else{ C.) 2 System.out.println("Hello World"); D.) 0 20 print(num-1); 21 } 22 } 19 Hint : Step through the program one line at time, keep track of the value stored in num.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!