Oracle
1Z0-808 · Question #98
1Z0-808 Question #98: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-808 to reveal the answer and full explanation for question #98. The question stem and answer options stay visible for context.
Working with Methods and Encapsulation
Question
Given:
public class Test2 {
public static void doChange(int[] arr) {
for (int pos = 0; pos < arr.length; pos++){
arr[pos] = arr[pos] + 1;
}
}
public static void main(String[] args) {
int[] arr = {10, 20, 30};
doChange(arr);
for (int x : arr) {
System.out.print(x + ", ");
}
doChange(arr[0], arr[1], arr[2]);
System.out.print(arr[0] + ", " + arr[1] + ", " + arr[2]);
}
}
What is the result?Options
- A11, 21, 31, 11, 21, 31
- B11, 21, 31, 12, 22, 32
- C12, 22, 32, 12, 22, 32
- D10, 20, 30, 10, 20, 30
- ECompilation fails
Unlock 1Z0-808 to see the answer
You've previewed enough free 1Z0-808 questions. Unlock 1Z0-808 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#method signatures#array vs primitive types#parameter matching#compilation errors