Given:
and this code fragment:What is the result?
Given:
and this code fragment:What is the result?
The correct answer is C. A compilation error occurs at line n1. In Java, resources that implement the AutoCloseable interface must be declared and initialized in the try-with-resources statement, which is not the case here. Instead, the resource res1 is being reassigned inside the try block, which causes a compilation error.
answer c, compilation error: Syntax error on token "res1", VariableDeclaratorId expected after this token
C,tested
C is the correct answer
Answer is C. Resource must be declared in try initialization block.
Answer C. A compilation error occurs at line n1. Simply put, to be auto-closed, a resource has to be both declared and initialized inside the try:
Answer is B
sorry, answer is C