What will be the output of this code?
try {
try {
throw new Exception("Inner");
} catch(Exception e) {
throw new RuntimeException("Outer");
}
} catch(RuntimeException e) {
System.out.println("Caught: " + e.getMessage());
}
Q.242Medium
In Java 8+, when using try-with-resources with multiple AutoCloseable resources, in what order are they closed?
Q.243Medium
Which of the following exceptions would NOT be caught by catching Exception class in Java?
Q.244Medium
Consider a scenario where you have nested try-catch blocks. If both inner and outer catch blocks match the thrown exception type, which one executes?
Q.245Medium
What does the getSuppressed() method of Throwable class return in context of try-with-resources?
Advertisement
Q.246Medium
In Java, when an exception is thrown in a try block and caught in a catch block, if the catch block also throws an exception, what happens to the original exception?
Q.247Medium
What is the default buffer size of BufferedReader in Java?
Q.248Medium
What happens when you try to read from a closed stream in Java?
Q.249Medium
Which of the following is a filtered stream?
Q.250Medium
Which class is used to read primitive data types from a stream?
Q.251Medium
Which of the following creates a bridge between character and byte streams?
Q.252Medium
What is the difference between FileInputStream and BufferedInputStream?
Q.253Medium
Which class allows reading and writing objects to a stream?
Q.254Medium
What is the mark() method used for in BufferedReader?
Q.255Medium
Which of the following statements will correctly read a file line by line?
Q.256Medium
What is the purpose of the skip() method in InputStream?
Q.257Medium
A Java program needs to read a file containing 10 million integers. Which approach would be most memory-efficient?
Q.258Medium
A serialized object contains a field marked as 'transient'. What happens to this field when the object is deserialized?
Q.259Medium
Which statement about ObjectOutputStream.reset() is correct?
Q.260Medium
When implementing Externalizable interface, which method is mandatory?
Java Programming MCQs – Free Practice Test | iGET | iGET