exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 92 discussion

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

Given the code fragment:

What is the result?

  • A. Invalid Name B. C. D.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

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
somrita90
3 months, 2 weeks ago
It should be a compilation error, due to syntax, for this line String names[] = ("Thomas", "Peter", "Joshep");
upvoted 2 times
yanoolthecool
1 week ago
keen eye
upvoted 1 times
...
...
Vicky_65
8 months, 2 weeks ago
C is correct
upvoted 1 times
...
carloswork
1 year, 1 month ago
Correct. Answer is C. In the first 'for', when trying to execute n.substring for the name "Peter", an exception will be thrown. So in the catch block it will print "Invalid Name", in the second 'for' it will print "omas" and the default values ​​of the remaining elements of the pwd array. It can be tested, iSnover give the source code below.
upvoted 1 times
...
iSnover
1 year, 2 months ago
Correnct is C, there are no comments to make. If you want to test the code: public class Main { public static void main(String[] args) { String names [] = {"Thomas", "Peter", "Joseph"}; String pwd [] = new String [3]; int idx = 0; try { for (String n: names) { pwd [idx] = n.substring(2, 6); idx++; } } catch (Exception e) { System.out.println ("Invalid Name"); } for (String p: pwd) { System.out.println (p); } } }
upvoted 3 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