259 câu trắc nghiệm tổng hợp Java cơ bản có đáp án

Đọc đoạn code sau: public class Test { public static void aMethod() throws Exception { try { throw new Exception(); } finally { System.out.println("finally"); } } public static

219/259

Đọc đoạn code sau:

public class Test {

 public static void aMethod() throws Exception {

 try {

 throw new Exception();

 } finally {

 System.out.println("finally");

 }

 }

 public static void main(String args[]) {

 try {

 aMethod();

 } catch (Exception e) {

 System.out.println("exception");

 }

 System.out.println("finished");

 }

}

Kết quả là gì?

Chọn một Câu trả lời

finally

exception, finished

finally, exception, finished

Lỗi biên dịch.

Giải thích

Chọn đáp án C