Question 186 of 481
1Z0-811 Arrays and Methods Practice Question
Given the code snippet: 'int[] nums = {10, 20, 30, 40}; int sum = 0; for (int i = 0; i < nums.length; i++) { sum += nums[i]; }'. What is the value of sum after execution?
⚠ Common exam trap
Oracle often tests whether candidates correctly compute the sum of all array elements versus partial sums, exploiting the common mistake of misinterpreting loop bounds or array indices.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
100
(100) because the for loop iterates over each element of the array {10, 20, 30, 40} and adds it to the sum variable. The sum starts at 0, and after adding 10, 20, 30, and 40, the total becomes 100.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
100
Why this is correct
Sums all four elements correctly.
- ✗
30
Why it's wrong here
Only sums first two elements.
- ✗
60
Why it's wrong here
Only sums first three elements.
- ✗
140
Why it's wrong here
Would require an extra element beyond array length.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 30, 2026
This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.