Question: Consider the following code segment and answer the questions below. Doing question 9 first might help you with questions 6 - 8 if you are

Consider the following code segment and answer the questions below. Doing question 9 first might help you with questions 6 - 8 if you are stuck. int i: int j: int[] arr = {6, 4, 7, 2, 1}: for (i = arr.length - 1: i > 1: i-) { System.out.println("Hello World!"): j = arr[i]: } 6. How many times will the above code print the sentence "Hello World!"? 7. What is the value of the integer variable i after executing the for loop? 8. What is the value of the integer variable j after executing the for loop? 9. Convert the for loop above to a while loop. You need to ensure that your code prints the sentence "Hello World!" the same number of times and ends with the same value for the integer value for the variables i and j. int i: int j: int[] arr = {6, 4, 7, 2, 1}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
