Question: 1. Consider the following piece of Java code: public static int[] reverse (int[] list) { int[] result = new int[list.length - 1]; for (int i
![1. Consider the following piece of Java code: public static int[]](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f393b58b8ba_09366f393b5099ee.jpg)
1. Consider the following piece of Java code: public static int[] reverse (int[] list) { int[] result = new int[list.length - 1]; for (int i = 0, j = result.length - 1; j >= 0; i++, j--) { result[j] = list[i]; } return result; } Write down, what will the method reverse return if it is being called with each of the following input parameters being passed to it (10 points each): a) int[] array1 = {1, 2, 3, 4}; b) int array2 [ ] {42, 0); 2. Consider the following array declaration and partial initialization: double[] xy = new double [10]; xy[0] = 1; xy[1] = 2; xy[3] xy[2] + xy[4]; What will each of the following statements print? Write it down right next to each println statement. (If you think some value is not defined, write "ND"). a) System.out.println(xy[0]); b) System.out.println(xv[31)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
