exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 80 discussion

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

Given the code fragment:

What is the result?

  • A. Answer = 0
  • B. Invalid calculation
  • C. Compilation fails only at line n1.
  • D. Compilation fails only at line n2.
  • E. Compilation fails at line n1 and line2.
Show Suggested Answer Hide Answer
Suggested Answer: E 🗳️

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
SamAru
Highly Voted 4 years, 6 months ago
Yes the answer is E, provided the declared variable num is used as is instead of nim
upvoted 5 times
...
MPignaProTech
Most Recent 2 months, 2 weeks ago
Selected Answer: E
Correct answer is E. compilation failed at Line n1 (missing semicolon) and at line n2 (cannot access variable "ans" outside the try catch)
upvoted 1 times
...
MPignaProTech
3 months ago
Selected Answer: C
semicolon is missing so correct answer is C
upvoted 1 times
...
Omar_Deeb
1 year, 4 months ago
compiles error on the third line
upvoted 1 times
...
dsms
1 year, 5 months ago
Selected Answer: C
correct answer is C. public static void main(String[] args) { try { int num = 10; int div = 0; int ans = num/div; }catch(ArithmeticException ae) { ans = 0 // Pay attention! No semicolon after zero !! }catch(Exception e) { System.out.println("Invalid calculation"); } System.out.println("Answer = " + ans); }
upvoted 1 times
dsms
1 year, 5 months ago
if there was a semicolon at the end of ans = 0, then the compiler would show two errors and the answer would be: error n1 and n2
upvoted 1 times
...
...
Vicky_65
1 year, 9 months ago
Selected Answer: E
botn n1 and n2 will causes compilation error.
upvoted 1 times
...
carloswork
2 years, 2 months ago
Selected Answer: E
Answer is E. The variable "ans" is being used outside its scope.
upvoted 1 times
...
juipeng
2 years, 7 months ago
public static void main(String[] args) { try { int num = 10; int div = 0; int ans = num/div; }catch(ArithmeticException ae) { ans = 0; }catch(Exception e) { System.out.println("Invalid calculation"); } System.out.println("Answer = " + ans); }
upvoted 2 times
...
Winston123
2 years, 7 months ago
Selected Answer: E
Checked
upvoted 1 times
...
EmilioDeBaku
3 years, 6 months ago
Answer is E
upvoted 3 times
...
machineallen
3 years, 8 months ago
line 1 is ok.
upvoted 2 times
Jimmyson
3 years, 1 month ago
Uyahlanya
upvoted 2 times
Kittyyyy
3 years, 1 month ago
Hahaha mara love
upvoted 1 times
...
...
...
notkniram
4 years, 1 month ago
Not Agree, Answer is D. I think there is a type in the question with nim. Compilation is ok on line1.
upvoted 1 times
notkniram
4 years, 1 month ago
Sorry Answer E is correct.
upvoted 2 times
...
...
v323rs
4 years, 12 months ago
Agree, the correct answer is "E" Compilation fails only at line n1 and line2.
upvoted 3 times
brianhuang881215
3 years, 4 months ago
cool it is only one answer! so does only two answers what a great grammer
upvoted 2 times
...
...
JoseCG
5 years, 2 months ago
Correct.
upvoted 2 times
JoseCG
4 years, 11 months ago
"ans" can't be resolve because is out of the block where was declared.
upvoted 12 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