- 16 If The Method Below Was Called With The Value 4 For Example Print 4 How Many Times Would Hello World Be Printed 1 (199.04 KiB) Viewed 39 times
16 If the method below was called with the value 4 (for example print(4)), how many times would “Hello World" be printed
-
- Site Admin
- Posts: 899603
- 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.