For Test:
public static void main(String[] args) {
int array1[] = {1, 2, 3};
int array2[] = new int[5];
array2 = array1;
for (int i : array2) {
System.out.print(i + " ");
}
System.out.println();
int array3[] = new int[3];
array3 = array2;
for (int i : array3) {
System.out.print(i + " ");
}
}
The answer is the letter D and there's not much to point out, when you reference an array that you had already instantiated along with arguments to another after the declaration, the variable starts to point to the other one, so it prints 1 2 3 1 2 3
upvoted 4 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
epicbrozo86
3 weeks agoiSnover
2 months ago