1Z0-811 Exception Handling and Development Tools • Complete Question Bank
Complete 1Z0-811 Exception Handling and Development Tools question bank — all 0 questions with answers and detailed explanations.
Refer to the exhibit.
```
Exception in thread "main" java.lang.NullPointerException
at com.example.MyClass.process(MyClass.java:25)
at com.example.Main.main(Main.java:10)
```Refer to the exhibit.
```
$ javac MyApp.java
MyApp.java:5: error: unreported exception FileNotFoundException; must be caught or declared to be thrown
FileReader fr = new FileReader("file.txt");
^
1 error
```Drag steps to the numbered slots on the right, or tap a step then tap a slot.
Drag a concept onto its matching description — or click a concept then click the description.
Prevents modification: variable constant, method override, class inheritance
Belongs to the class rather than instances
Cannot be instantiated; used for classes and methods
Ensures mutual exclusion in multithreading
Marks field to be ignored during serialization
Exception in thread "main" java.lang.NullPointerException
at com.example.MyClass.methodA(MyClass.java:25)
at com.example.MyClass.main(MyClass.java:10)error: unreported exception java.io.IOException; must be caught or declared to be thrown
br.readLine();
^public class InvalidInputException extends Exception {
public InvalidInputException(String message) {
super(message);
}
}Given the following try-catch block: try { // some code
} catch (IOException | NumberFormatException e) {e = new IOException("wrapper"); // throw e;
}
Which line causes a compilation error?
Exception in thread "main" java.io.FileNotFoundException: /data/config.txt (Permission denied)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at com.example.ConfigLoader.load(ConfigLoader.java:35)
at com.example.Main.main(Main.java:12)$ javac -d bin -cp lib/*.jar src/com/example/App.java warning: [path] bad path element "lib/*.jar": No such file or directory
public class ResourceHandler {
public void process() throws IOException {
try (FileInputStream fis = new FileInputStream("data.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fis))) {
// read file
} catch (IOException e) {
throw e;
}
}
}Consider the following code snippet:
public int getValue() {try {
return 1;
} catch (Exception e) {
return 2;
} finally {
return 3;
}
}What does the method return?
Exception in thread "main" java.lang.ArithmeticException: / by zero at com.example.Calculator.divide(Calculator.java:12) at com.example.Main.main(Main.java:5)