3. Consider the following:
final int[] myArray = { 1,2 };
myArray[1] = 3;
System.out.println (myArray[1]);
What is printed?

4. Given:
String words = {“Happy”, “Birthday” , “to”, “you”};
int i = 0;
j = words.length-1; String temp;
while (i < j ) {
temp = words[i];
words[i] = words[j];
words[j] = temp;
i++;
j--;
}
What is stored in words at the completion of the while loop?

5. Given:
int [] nums = {-2, -1, 0, 1, 2};
int k;
for (k = 0; k < nums.length; k++) {
nums[k] -=sign (nums[k]) //sign returns 1 if k is pos,
// -1 if k is neg, and 0 if k is 0
nums[k] += sign(nums[k]);
}
What are the value of the elements of nums after the for loop?

6. Consider the following code segment:
1. int [] A = new int [3];
2. int [] B = new int [10];
3. B[9] = 30;
4. A = B;
5. A[9] = 20;
6. B[9] = 10;
7. System.out.println (A[9]);
Trace what happens in memory for the above steps 1 – 7. What is the output?

Respuesta :

The true statements are:

  • 3. The output is 3
  • 4. At the end of the completion of the loop, {"you", "to", "Birthday", "Happy"} is saved in words
  • 5. After the for loop, all the elements of nums become 0
  • 6. The output on line 7 is 10

Program 3

The flow of the program is that:

  • The program changes the index 1 element of the integer array myArray to 3
  • This element is then printed, afterwards

Hence, the output is 3

Program 4

The flow of the program is that:

  • The elements of the string array words are reversed
  • These elements are then printed, afterwards

Hence, at the end of the completion of the loop, {"you", "to", "Birthday", "Happy"} is saved in words

Program 5

The flow of the program is that:

  • The elements of the integer array nums are reduced or increased to 0
  • These elements are then printed, afterwards

Hence, after the for loop, all the elements of nums become 0

Program 6

The flow of the program is that:

  • Lines 1 and 2 declare integer arrays A and B
  • Line 3 sets B[9] to 30
  • Line 6 sets B[9] to 10
  • Line 4 changes the length of array A to 10, and the same elements are saved in A and B

Hence, the output on line 7 is 10

Read more about arrays at:

https://brainly.com/question/15683939