exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 122 discussion

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

Given the code fragment:

What is the result?

  • A. 3
  • B. 4
  • C. -1
  • D. Compilation fails.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

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
DJava
Highly Voted 5 years, 5 months ago
Answer A: Result 3
upvoted 18 times
...
MPignaProTech
Most Recent 1 month, 4 weeks ago
Selected Answer: D
compilation fails for semicolon minsing
upvoted 1 times
...
duydn
1 year, 3 months ago
Selected Answer: D
D is correct, array cannot assign by ("element")
upvoted 1 times
...
dsms
1 year, 4 months ago
Selected Answer: D
Correct answer is: Compilation fails. String days[] = ("sun", "mon", "wed", "sat"); there must be { } not ()
upvoted 2 times
...
RAADEL3IMLAK
1 year, 10 months ago
answer is A, is tested : int wd = 0; String days[] = {"sun", "mon", "wed", "sat"}; for (String s : days) { switch (s) { case "sat": case "sun": wd--; System.out.println(wd + " sun "); break; case "mon": wd++; System.out.println(wd + " mon "); case "wed": wd += 2; System.out.println(wd + " wed "); } } System.out.print(wd + " "); result is -1 sun 0 mon 2 wed 4 wed 3 sun 3
upvoted 2 times
...
akbiyik
2 years ago
Selected Answer: A
Answer is A
upvoted 1 times
...
iSnover
2 years, 2 months ago
Selected Answer: D
The answer is D, the array parentheses were instantiated wrong, it's "{}" instead of "[]".
upvoted 1 times
...
iSnover
2 years, 2 months ago
Selected Answer: D
The array instantiation is wrong, it is {} instead of [] and this causes a compilation error. If the array was with {} it would compile. So the answer is letter D.
upvoted 2 times
iSnover
2 years, 2 months ago
If the array were instantiated correctly, it would print 3 which is the answer to the letter A.
upvoted 2 times
...
...
Lavz5
2 years, 3 months ago
Correct Answer is B. Since there is no break statement for "mon" it will execute next case statement also
upvoted 1 times
...
hexadecimal82
2 years, 5 months ago
Selected Answer: A
if we consider that the parenthesis in array 'days' is a typo, then the answer is A. Else the ans would be D
upvoted 1 times
...
archer1903
2 years, 6 months ago
Selected Answer: D
Answer is D. there should be curly braces instead of parentheses
upvoted 1 times
...
lnrdgst
2 years, 10 months ago
Testing in my IDE, the answer that most convinces me is the letter D. An error occurs in the attribution signal. When I remove the parentheses and insert braces the error disappears
upvoted 2 times
...
EmilioDeBaku
3 years, 5 months ago
Answer is A
upvoted 2 times
...
SSJ5
3 years, 8 months ago
Correct answer A
upvoted 1 times
...
Omegaric
4 years ago
Correct answer is A, result is 3 public class Test { public static void main(String[] args) { int wd = 0; String days[] = {"sun", "mon", "wed", "sat"}; for (String s : days) { switch (s) { case "sat": case "sun": wd--; break; case "mon": wd++; case "wed": wd = wd + 2; } } System.out.print(wd + " "); } }
upvoted 1 times
...
Melaena
4 years ago
After correcting the parentheses () around the array values {should be curly brackets} Result is 3. Tested in IntelliJ.
upvoted 1 times
...
pg13
4 years, 5 months ago
Answer:A
upvoted 1 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