exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 21 discussion

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

Given the code fragment:

Which modification enables the code fragment to print TrueDone?

  • A. Replace line 5 With String opt = "true"; Replace line 7 with case "true":
  • B. Replace line 5 with boolean opt = l; Replace line 7 with case 1:
  • C. At line 9, remove the break statement.
  • D. Remove the default section.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
M_Jawad
Highly Voted 4 years, 11 months ago
Answer is A : Boolean can't be used in switch
upvoted 22 times
...
vic88
Most Recent 1 week, 6 days ago
Selected Answer: A
A is the answer
upvoted 1 times
...
arjunrawatirissoftware
1 year, 2 months ago
Answer -A
upvoted 1 times
...
duydn
1 year, 3 months ago
Selected Answer: A
Switch cannot accept Boolean. A is correct
upvoted 1 times
...
Sreeni_A
1 year, 3 months ago
Answer is A
upvoted 1 times
...
sylwia000001
1 year, 7 months ago
Answer is A
upvoted 1 times
...
sylwia000001
1 year, 7 months ago
public class Test { public static void main(String[] args) { String opt = "true"; switch (opt) { case "true": System.out.print("True"); break; default: System.out.print("***"); } System.out.println("Done"); } }
upvoted 1 times
...
Vicky_65
1 year, 8 months ago
Selected Answer: A
Option is A.Because boolean type is not allowed in switch statement.
upvoted 1 times
...
hexadecimal82
2 years, 5 months ago
Selected Answer: A
Obviously it's A
upvoted 2 times
...
Mthlagi
2 years, 10 months ago
Correct Answer is A.
upvoted 1 times
...
alexandrustefanescu
3 years, 5 months ago
Answer A correct switch doesn't check boolean values
upvoted 2 times
...
Fuego_412_
3 years, 12 months ago
A is correct, you cannot have a boolean, double or long in a switch statement thus B is incorrect. C would result in the default statement being printed out
upvoted 2 times
...
bobob
4 years, 3 months ago
The switch takes as input only String and int
upvoted 3 times
Anton2020
3 years, 2 months ago
There are more options: char, byte, short, Character, Byte, Short, Integer or enum
upvoted 5 times
...
...
Gyzmou
4 years, 4 months ago
A correct
upvoted 3 times
...
SamAru
4 years, 5 months ago
Agreed Answer is option A!
upvoted 2 times
...
v323rs
4 years, 11 months ago
Agree, the correct answer "A" Replace line 5 With String opt = "true"; Replace line 7 with case "true":
upvoted 4 times
...
dya45792
5 years ago
Antwort B ergibt kein sinn , also es muss ein String sein , und bei C und D auslassen oder nicht kommt nur ; DONE raus public static void main(String[] args) { String opt = " true"; switch (opt) { case "true": System.out.print("True"); // break; // default: System.out.print("***"); } System.out.println("Done"); } } also nur Done / oder ?
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