Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 182

Given:

and

What is the result?

    Correct Answer: C

    First, the constructor of the Resource class is called, which prints 'A'. Then, the printResource method is called, which prints 'C'. After the try block is finished, the close method is called automatically because the Resource class implements AutoCloseable, which prints 'B'. Finally, the code in the finally block is executed, which prints 'D'. The final output is 'ACBD'.

Discussion
d7bb0b2Option: C

C IS CORRECT 1- new resource() print -> A 2- r.printResource() print C 3- close is called when try blick is finished so PRINT B 4- finally print D