Given:
public static void main(String[] args) throws Exception {
try {
processFile();
} catch(Exception e) {
Throwable [] t = e.getSuppressed();
}
public static void processFile() throws IOException {
try (FileReader fr = new FileReader"logfilesrc.txt");
FileWriter fw = new FileWriter("logfiledest.txt")) {{
java.util.zip.ZipFile zf = new java.util.zip.ZipFile("alllogs.zip");
System.out.println("Created files for logs");
}
The getSuppressed method returns an array of __________.
A.
Allexceptions that were thrown in the processFile method but were suppressed.
B.
Exceptions suppressed because that are not declared in the throws clause.
C.
Only runtime exceptions that were thrown in the processFile method but were suppressed.
D.
Only runtime exceptions that were thrown in the processFile method but were not declared in
throws clause.
Explanation:
The GetSuppressed() methodreturns an array containing all of the exceptions that
were suppressed, typically by the try-with-resources statement, in order to deliver this exception.
If an exception is thrown from the try block and one or more exceptions are thrown from the trywith-resources statement, then those exceptions thrown from the try-with-resources statement are
suppressed.
Reference: The Java Tutorials,Suppressed Exceptions