1Z0-805 · Question #15
Given: public static void main(String[] args) throws Exception { try { processFile(); } catch(Exception e) { Throwable [] t = e.getSuppressed(); } } public static void processFile() throws…
The correct answer is A. Allexceptions that were thrown in the processFile method but were suppressed. 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 try…
Question
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"); Oracle 1Z0-805 Exam } } The getSuppressed method returns an array of __________.
Options
- AAllexceptions that were thrown in the processFile method but were suppressed.
- BExceptions suppressed because that are not declared in the throws clause.
- COnly runtime exceptions that were thrown in the processFile method but were suppressed.
- DOnly runtime exceptions that were thrown in the processFile method but were not declared in throws clause.
How the community answered
(39 responses)- A82% (32)
- B3% (1)
- C10% (4)
- D5% (2)
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 try- with- resources statement, then those exceptions thrown from the try-with-resources statement are
Topics
Community Discussion
No community discussion yet for this question.