exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 24 discussion

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

Given the code fragment:

What is the result?

  • A. Sum is 600
  • B. Compilation fails at line n1.
  • C. Compilation fails at line n2.
  • D. A ClassCastException is thrown at line n1.
  • E. A ClassCastException is thrown at line n2.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
vic88
1 week, 6 days ago
Selected Answer: B
B is answer
upvoted 1 times
...
arjunrawatirissoftware
1 year, 2 months ago
Answer - B
upvoted 2 times
...
fvelazqueznava
1 year, 2 months ago
Selected Answer: B
not compile at N1
upvoted 1 times
...
duydn
1 year, 3 months ago
Selected Answer: B
Short and Integer cannot cast to String -> B
upvoted 1 times
...
NabilBenAsker
1 year, 5 months ago
Selected Answer: B
Short and Integer cannot convert to String. to fix this issue you must to change to String s3=String.valueOf(s1+s2)
upvoted 1 times
...
NabilBenAsker
1 year, 5 months ago
Tested answer B Short cannot be converted to String
upvoted 2 times
...
Kolodets
1 year, 7 months ago
ClassCastException impossible, because inconvertible types => Compilation fails at N1
upvoted 1 times
...
Ankit1010
1 year, 10 months ago
B is the correct answer as cannot cast int to java.lang.String.
upvoted 4 times
...
carloswork
2 years, 1 month ago
Selected Answer: B
Tested, answer is B. Source code to test: public static void main(String[] args) { Short s1 = 200; Integer s2 = 400; String s3 = (String) (s1 + s2); // line n1 Long s4 = (long) s1 + s2; // line n2 System.out.println("Sum is " + s3); } A correct convert to string could be: String s3 = String.valueOf(s1 + s2);
upvoted 4 times
...
UAK94
2 years, 2 months ago
Correct is B. Because the ClassCastException is a RuntimeException and it may not affect compilation. But here ceompilation fails at n1.
upvoted 2 times
...
iSnover
2 years, 2 months ago
Selected Answer: B
Correct is B. Because the ClassCastException occurs when we try to cast to a PRIMITIVE variable type that does not hold the variable's value. String is not a primitive type and a primitive type cannot cast to a non-primitive type, error occurs when executing code on line n1.
upvoted 3 times
...
Rdharma
2 years, 2 months ago
B is the answer. int cannot be converted to String
upvoted 1 times
...
Philip0908
2 years, 3 months ago
Selected Answer: B
line n1 will not compile
upvoted 1 times
...
TD844
2 years, 3 months ago
Selected Answer: B
incompatible types: int cannot be converted to java.lang.String.
upvoted 2 times
...
RoxyFoxy
2 years, 3 months ago
Selected Answer: B
incompatible types: int cannot be converted to java.lang.String!
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