Question: Consider the following method, mystery2: What are the values of the elements in array a1 after the following code executes? int[] a1 = {2, 4,

Consider the following method, mystery2:

public static void mystery2 (int [] a, int[] b) { for (int i = 0; i < a.length; i++) { %3D a[i] = a[2 * i % a.length] - b[3 * i % b.length];

What are the values of the elements in array a1 after the following code executes?

int[] a1 = {2, 4, 6, 8, 10, 12, 14, 16};
int[] a2 = {1, 1, 2, 3, 5, 8, 13, 21};
mystery2(a1, a2);

public static void mystery2 (int [] a, int[] b) { for (int i = 0; i < a.length; i++) { %3D a[i] = a[2 * i % a.length] - b[3 * i % b.length];

Step by Step Solution

3.51 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

After the mystery2 method ... View full answer

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 Building Java Programs A Back to Basics Approach Questions!