exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 121 discussion

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

Given:
and the code fragment:

What is the result?

  • A. An exception is thrown at line n2.
  • B. 100
  • C. A compilation error occurs because the try block is declared without a catch or finally block.
  • D. A compilation error occurs at line n1.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
Community vote distribution
B (100%)

Comments

Chosen Answer:
This is a voting comment. You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Tarik2190
Highly Voted 3 years, 3 months ago
Answer is B, class MyClass implements AutoCloseable { int test; public void close() { } public MyClass copyObject() {return this;} } public class Test { public static void main (String[] args) throws InterruptedException { MyClass obj = null; try (MyClass obj1 = new MyClass()) { obj1.test = 100; obj = obj1.copyObject(); } System.out.println(obj.test); } }
upvoted 5 times
...
steefaand
Most Recent 7 months ago
Selected Answer: B
Answer is B. Tested.
upvoted 1 times
...
duydn
11 months, 3 weeks ago
Selected Answer: B
B is correct, this is Try-with-resource, and need implement AutoCloseable interface.
upvoted 1 times
...
jduarte
3 years, 7 months ago
answer B. Tested
upvoted 2 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:
AZ-305
Seoul, 1 minute ago