Oracle
1Z0-819 · Question #118
1Z0-819 Question #118: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #118. The question stem and answer options stay visible for context.
Question
Given:
public static void print(int[] nums) {
// Add code here
}
Which of the following code fragments can be inserted within the print() method, so that all the numbers from 1 to 5 are printed to the console?
Options
- Afor (int i=0; i<10 && i<nums.length;){ System.out.println(nums[i]);}
- Bfor (var i=0; i<nums.length; ++i){ System.out.println(nums[i]);}
- Cfor (int i = nums.length; i>=0; i--){ System.out.println(nums[i]);}
- Dfor (int i=0; j=0; i<nums.length-1; ++i){ System.out.println(nums[i]);}
- Efor (var i=0; j=0; i<nums.length-1; ++i){ System.out.println(nums[j]);}
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 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.