exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 176 discussion

Actual exam question from Oracle's 1z0-808
Question #: 176
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: 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
MPignaProTech
2 months, 3 weeks ago
Selected Answer: D
ans has not been initialized. Good answer is D
upvoted 1 times
...
jackymak
1 year, 7 months ago
Selected Answer: D
public static void main(String[] args) { int ans; try { int num = 10; int div = 0; ans = num / div; } catch (ArithmeticException ae) { ans = 0; } catch (Exception e) { System.out.println("Invalid calculation"); } System.out.println("Ans = " + ans); }
upvoted 1 times
...
TOPPSI
1 year, 12 months ago
Anwser is D. Variable 'ans might not have been initialized.
upvoted 2 times
...
carloswork
2 years, 2 months ago
Selected Answer: D
Answer is D. To test: public static void main(String[] args) { int ans; try { int num = 10; int div = 0; ans = num / div; } catch (ArithmeticException ae) { ans = 0; // line n1 } catch (Exception e) { System.out.println("Invalid calculation"); } System.out.println("Answer = " + ans); // line n2 }
upvoted 1 times
...
iSnover
2 years, 3 months ago
Selected Answer: D
The correct answer is the letter D, the compilation fails on line n2 because if you catch the exception "e" the variable "ans" was not started, causing a compilation error.
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