To add to the explanation: The JVM throws a null pointer exception because a method (concat()) is called on an object containing null. Note that the print() method does not cause JVM to throw an exception and prints null.
D is right.
During each iteration:
First iteration (idx = 0):
strs[0] is null.
strs[idx].concat(" element " + idx) attempts to call concat on null, which leads to a NullPointerException.
Correct
D. A NullPointerException is thrown at runtime.
upvoted 3 times
...
This section is not available anymore. Please use the main Exam Page.1z0-808 Exam Questions
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.
Saftschnitzel
Highly Voted 5 years, 3 months agoletmein2
Highly Voted 6 years agovic88
Most Recent 7 months, 1 week agoVicky_65
2 years, 3 months agoodzio33
2 years, 5 months agoakbiyik
2 years, 7 months agotawa_z58
2 years, 7 months agov323rs
5 years, 6 months ago