exam questions

Exam 1z0-808 All Questions

View all questions & answers for the 1z0-808 exam

Exam 1z0-808 topic 1 question 167 discussion

Actual exam question from Oracle's 1z0-808
Question #: 167
Topic #: 1
[All 1z0-808 Questions]

Given:

What is the result?

  • A. 97 98 99 100 null null null
  • B. 97 98 99 100 101 102 103
  • C. Compilation fails.
  • D. A NullPointerException is thrown at runtime.
  • E. An ArraylndexOutOfBoundsException is thrown at runtime.
Show Suggested Answer Hide Answer
Suggested Answer: E 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
DriftKing
3 months, 3 weeks ago
Selected Answer: E
E. An ArraylndexOutOfBoundsException is thrown at runtime. chs[a][b] = "" + i; --> this line will throw ArraylndexOutOfBoundsException as first row ie., ch[0] is of size 2 and chs.length is 5. When loops goes to ch[0][3] which is greater than size 2, it will throw exception.
upvoted 2 times
...
iSnover
1 year, 3 months ago
Selected Answer: E
The answer is the letter E. Here is the code: public static void main(String[] args) { String [] [] chs = new String[5][2]; chs [0] = new String [2]; chs [1] = new String [5]; int i = 97; for (int a = 0; a < chs.length; a++) { for (int b = 0; b <chs.length; b++) { chs[a] [b] = "" + i; i++; } } for (String[] ca : chs) { for (String c : ca) { System.out.print(c + " "); } System.out.println(); } }
upvoted 4 times
...
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago