preface : I wanted to use pictures , As a result, if you can't send it out, you can use words .
one , exception handling - task
exception handling - task
Question quantity : 10 Full mark : 100
one . Single choice questions ( common 8 topic ,80 branch )
1. ( Single choice questions )
In method , The keyword used when throwing an exception object is ( )
* A. throw
* B. catch
* C. finally
* D. throws
My answer : A right key : A
10 branch
Answer analysis :
2. ( Single choice questions )
When customizing exception class , The classes that can be inherited are ( )
* A. Error
* B. Applet
* C. Throwable,Exception And its subclasses
* D. AssertionError
My answer : C right key : C
10 branch
Answer analysis :
3. ( Single choice questions ) For statements that have been defined and may throw exceptions , When programming ( ).
* A. Must use try/catch Statement handling exception , Or use throws Throw it out in the method header declaration .
* B. If the program is wrong , Must use try/catch Statement handling exception .
* C. You can ignore it .
* D.
Only use try/catch Statement processing .
My answer : A right key : A
10 branch
Answer analysis :
4. ( Single choice questions )catch Can only be captured in a statement ( ) Object of type
* A. Throwable
* B. Object
* C. Exception
* D. RuntimeException
My answer : C right key : C
10 branch
5. ( Single choice questions ) The statements that catch exceptions in methods are ( )
* A. try
* B. catch
* C. throw
* D. StackTrace
My answer : B right key : B
10 branch
6. ( Single choice questions ) about catch Arrangement of exceptions in Clause , Which of the following is true ( )
* A. Parent class exception first , Subclass exception after
* B. Subclass exception first , Parent class exception after
* C. Exceptions with inheritance cannot be in the same try In program segment
* D. Exceptions can be arranged in any order , It has nothing to do with order
My answer : A right key : B
0 branch
7. ( Single choice questions )
Based on the following code , analysis method() Output of method after exception .
private static void try() {
try {
System.out.println("A");
method(); // Runtime exceptions may be thrown
System.out.println("B");
return;
} catch (Exception e) {
System.out.println("D");
} finally {
System.out.println("E");
}
System.out.println("F");
return;
}
* A.
A
B
D
E
F
* B.
A
D
B
* C.
A
D
E
F
* D.
A
B
My answer : C right key : C
10 branch
Answer analysis :
8. ( Single choice questions )
Based on the following code , analysis method() The output result after the method does not throw an exception .
private static void try() {
try {
System.out.println("A");
method(); // Runtime exceptions may be thrown
System.out.println("B");
return;
} catch (Exception e) {
System.out.println("D");
} finally {
System.out.println("E");
}
System.out.println("F");
return;
}
* A.
A
B
E
* B.
A
B
E
F
* C.
A
B
* D. None of it
My answer : B right key : B
10 branch
Answer analysis :
two . Judgment question ( common 2 topic ,20 branch )
9. ( Judgment question )
Java Once an exception occurs in the program, the whole program will be terminated .
* A. yes
* B. wrong
My answer : Wrong or correct answer : wrong
10 branch
10. ( Judgment question )
RuntimeException Runtime exceptions must be explicitly captured and handled
* A. yes
* B. wrong
My answer : Wrong or correct answer : wrong
10 branch
Technology
Daily Recommendation