Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Oracle Exam 1Z0-809 Topic 14 Question 65 Discussion

Actual exam question for Oracle's 1Z0-809 exam
Question #: 65
Topic #: 14
[All 1Z0-809 Questions]

Given the code fragment:

public static void main (String[] args) throws IOException {

BufferedReader brCopy = null;

try (BufferedReader br = new BufferedReader (new FileReader(''employee.txt''))) { //

line n1

br.lines().forEach(c -> System.out.println(c));

brCopy = br;//line n2

}

brCopy.ready(); //line n3;

}

Assume that the ready method of the BufferedReader, when called on a closed BufferedReader, throws an exception, and employee.txt is accessible and contains valid text.

What is the result?

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Deangelo
1 months ago
Haha, this question is like a game of BufferedReader roulette! I think the answer is D, but I wouldn't be surprised if the exam gods throw us a curve ball. Gotta stay on our toes, folks!
upvoted 0 times
...
Edelmira
1 months ago
Whoa, this is a tricky one! My money's on D. The code will print the file and then throw an exception when we try to use the closed BufferedReader. Gotta love those try-with-resources blocks!
upvoted 0 times
Ines
2 days ago
Yeah, I agree. The code will print the file and then throw an exception at line n3.
upvoted 0 times
...
Temeka
15 days ago
I think you're right, D seems like the correct answer here.
upvoted 0 times
...
...
Emily
1 months ago
Haha, this question is a real brain-teaser! I'd say the answer is C. The code is trying to assign a closed BufferedReader to the brCopy variable, which should result in a compilation error.
upvoted 0 times
...
Frank
2 months ago
I think the answer is A. The ready() method is being called on a closed BufferedReader, so it should throw a compilation error at line n3.
upvoted 0 times
Carla
2 days ago
That makes sense. It's important to remember the behavior of methods when working with BufferedReader.
upvoted 0 times
...
Jolene
6 days ago
Yes, you're right. Calling ready() on a closed BufferedReader will indeed result in a compilation error at line n3.
upvoted 0 times
...
Barrett
13 days ago
I think the answer is A. The ready() method is being called on a closed BufferedReader, so it should throw a compilation error at line n3.
upvoted 0 times
...
Talia
19 days ago
I agree with you, it should be D. The code will print the content of the file before throwing an exception at line n3.
upvoted 0 times
...
Carissa
1 months ago
No, I believe the answer is D. The code will print the content of the employee.txt file and then throw an exception at line n3.
upvoted 0 times
...
Avery
1 months ago
I think the answer is A. The ready() method is being called on a closed BufferedReader, so it should throw a compilation error at line n3.
upvoted 0 times
...
...
Andree
2 months ago
The correct answer is D. The code will print the content of the employee.txt file and throw an exception at line n3. This is because the BufferedReader is closed at the end of the try-with-resources block, but we're still trying to call the ready() method on the brCopy reference, which will result in an exception.
upvoted 0 times
Teri
4 days ago
You're welcome!
upvoted 0 times
...
Kirk
19 days ago
Oh, I see. Thanks for clarifying.
upvoted 0 times
...
Bong
1 months ago
No, it's actually D. The code will print the content of the employee.txt file and throw an exception at line n3.
upvoted 0 times
...
Noel
1 months ago
I think the answer is A.
upvoted 0 times
...
...
Kanisha
2 months ago
Hmm, that makes sense too. Let's see what others think before making a final decision.
upvoted 0 times
...
Zana
2 months ago
I disagree, I believe the answer is D) because the code will print the content of the file before throwing an exception at line n3.
upvoted 0 times
...
Kanisha
3 months ago
I think the answer is A) because calling ready() on a closed BufferedReader will throw an exception.
upvoted 0 times
...

Save Cancel