Question | Answer |
All types of exception are subclass of ... | java.lang.Throwable |
The ... block executes regardless of whether the ... block throws an ... | finally, try, exception |
true or false for the try block, you can define only single catch block, and multiple finally blocks | false |
A finally block is used to define ... code - code that closes and releases resources, such as file handlers and database or network connection | cleanup code |
Is it possible to define a finally block before a catch block ? | No, compilation error |
if a catch block returns a primitive data type, the finally block ... modify the value being returned | can't modify |
if a catch block returns an object, the finally block ... modify the value being returned | can modify |
Can an exception or error be rethrowen? | yes |
True or false Unhandled exceptions thrown by an inner exception handler are passed on to the outer try-catch block to handle | true |
Exceptions can be divided into three categorie | Checked exceptions Unchecked exceptions (Runtime exceptions) Errors |
What is a checked exception ? | Is an unacceptable condition foreseen by the author of the method but outside the immediate control of the code. |
A checked exception is s subclass of ... | java.lang.Exception |
What is a runtime exception? | is a representation of a programming error. These occur from inappropriate use of another piece of code. |
A Unchecked exception is a subclass of .. | java.lang.RuntimeException |
Is a runtime exception a part of the method signature? | Not always |
what's an error? | A serious exception thrown by the JVM as a result of an error in the environment state that processes your code |
An error is a subclass of class ... | java.lang.Error |
Does an error need to be a part of a method signature? | N O |
Can you catch an Error? | yes, but you shouldn't handle errors in your code |
java.lang.ArrayIndexOutOfBoundsException is a.. Thrown when .. | Runtime exception, derived from IndexOutOfBoundsException. When a piece of code tries to access an array out of its bounds |
java.lang.IndexOutOfBoundsException is a.. Thrown when.. | Runtime exception. When a piece of code tries to access an list using a illegal index |
java.lang.ClassCastException is a .. Thrown when .. | Runtime exception When an object fails an IS-A test with the class type to which it's casting |
java.lang.IllegalArgumentException is a.. Thrown when .. | Runtime exception to specify that a method has passed illegal or inappropriate arguments |
java.lang.IllegalStateException is a .. Thrown when .. | Runtime exception a method has been invoked at an illegal or inappropriate time |
NullPointerException is a .. Thrown when .. | Runtime exception a method or a variable with a null value is accessed |
NumberFormatException is a .. Thrown when .. | Runtime exception an appropriate format to one of the numeric types |
ExceptionInInitializerError is a .. Thrown when .. | Error by the JVM when a static initializer in a code throws any of RuntimeException |
A ExceptionInInitializerError can only be caused by a .. | RuntimeException |
Can you throw an unhandled checked exception from a static initializer ? | No |
StackOverflowError is a .. Occurs when .. | Error, derived from VirtualMachineError when a program calls itself so many times that the memory allocated to execute the Java program "overflows" |
NoClassDefFoundError is a .. Occurs when .. | Error, derived from LinkageError you failed to set your class path and, as a result, the JVM was unable to load the class that you wanted to access or to execute Or you run your application before compiling it |
OutOfMemoryError is a .. Occurs when .. | Error, derives from VirtualMachineError When the JVM run out of memory on the heap, and the garbage collector may not be able to free memory for the JVM |
Want to create your own Flashcards for free with GoConqr? Learn more.