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[]

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!