1Z0-803 · Question #1
Given: Which two actions, used independently, will permit this class to compile?
The correct answer is C. Adding throws IOException to the main() method signature and to the dosomething() method D. Adding throws IOException to the dosomething() method signature and changing the catch argument. The IOException must be caught or be declared to be thrown. We must add a throws exception to the doSomething () method signature (static void doSomething() throws IOException). Then we can either add the same throws IOException to the main method (public static void main(String[
Question
Given:
Which two actions, used independently, will permit this class to compile?
Exhibit
Options
- AAdding throws IOException to the main() method signature
- BAdding throws IOException to the doSoomething() method signature
- CAdding throws IOException to the main() method signature and to the dosomething() method
- DAdding throws IOException to the dosomething() method signature and changing the catch argument
- EAdding throws IOException to the main() method signature and changing the catch argument to
How the community answered
(44 responses)- A14% (6)
- B2% (1)
- C77% (34)
- E7% (3)
Explanation
The IOException must be caught or be declared to be thrown. We must add a throws exception to the doSomething () method signature (static void doSomething() throws IOException). Then we can either add the same throws IOException to the main method (public static void main(String[] args) throws IOException), or change the catch statement in main to IOException.
Topics
Community Discussion
No community discussion yet for this question.
