exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 156 discussion

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

Given:



What is the result?

  • A. The compilation fails.
  • B. An unchecked exception is thrown at run time.
  • C. Error reading files is printed on the console.
  • D. The content from filel.txt and file2.txt is printed on the console.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
Community vote distribution
A (100%)

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
ASPushkin
6 months, 2 weeks ago
Selected Answer: A
In both cases reader1 is effectively final : BufferedReader reader1 = new BufferedReader(new FileReader("journaldev.txt")); try (reader1) { System.out.println(reader1.readLine()); //reader1 = Error effectively final } catch (IOException e) { System.out.println(reader1); } } or try (BufferedReader reader1 = new BufferedReader(new FileReader("journaldev.txt"));) { System.out.println(reader1.readLine()); //reader1 = Error effectively final } catch (IOException e) { }
upvoted 1 times
...
d7bb0b2
8 months ago
Selected Answer: A
Variables in try with resource are implicit final, so if you try to asing a new value in try block no compile time error.
upvoted 1 times
...
Omnisumem
10 months, 4 weeks ago
Selected Answer: A
Tested: A. auto-closeable resource reader may not be assigned reader = new BufferedReader (new FileReader(file2)); ^ 1 error error: compilation failed
upvoted 1 times
...
Stavok
1 year, 1 month ago
Selected Answer: A
A is correct Exception in thread "main" java.lang.Error: Unresolved compilation problem: The resource reader of a try-with-resources statement cannot be assigned
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:
2V0-21.23
Bengaluru, 1 minute ago