Deck 10: Exceptions

ملء الشاشة (f)
exit full mode
سؤال
Which of the following exceptions are unchecked?

A) RuntimeException
B) IllegalAccessException
C) NoSuchMethodException
D) ClassNotFoundException
E) none of the above
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Every line in a catch block is guaranteed to be executed in all situations.
سؤال
A(n) ____________________ can be used to find the exact line where an exception was thrown during program execution.

A) interface
B) call-stack trace
C) try block
D) catch block
E) none of the above
سؤال
Which of the following represents the standard input stream?

A) System.in
B) System.out
C) System.err
D) System.instream
E) System.outstream
سؤال
A(n) _____________________ is an object that defines an unusual or erroneous situation that is typically recoverable.

A) error
B) exception
C) interface
D) try block
E) catch block
سؤال
A(n) ________________ is an ordered sequence of bytes.

A) exception
B) error
C) input-output flow
D) stream
E) none of the above
سؤال
A(n) ____________________ is used to identify a block of statements that may cause an exception.

A) call-stack trace
B) error
C) catch block
D) try block
E) none of the above
سؤال
Which of the following file streams should be explicitly closed to ensure that written data is properly retained?

A) output
B) input
C) error
D) writable
E) readable
سؤال
Which of the following exception types must always be caught unless they are contained in methods that throw them in the method header?

A) file stream
B) IO
C) checked
D) unchecked
E) none of the above
سؤال
The Exception class and the Error class are subclasses of the ___________________ class.

A) Throwable
B) Catchable
C) RuntimeProblem
D) CompilerProblem
E) none of the above
سؤال
Unchecked exceptions must be caught or propogated, or a program will not compile.
سؤال
The _________________ statement is used to begin exception propogation.

A) propogate
B) relay
C) throw
D) except
E) send
سؤال
Every line of a(n) __________________ is executed no matter what exceptions are thrown.

A) try block
B) call stack trace
C) catch block
D) interface
E) finally block
سؤال
If an exception is not caught, a program will __________________________ .

A) not compile
B) terminate abnormally
C) print a message and continue executing
D) all of the above
E) neither a, b nor c
سؤال
A finally clause is always required in a try-catch block.
سؤال
Attempting to divide by zero will result in an Error being thrown, not an Exception.
سؤال
A(n) _____________________ is an object that defines an erroneous situation from which the program usually cannot recover.

A) error
B) exception
C) interface
D) try block
E) catch block
سؤال
Which of the following methods are part of the Exception class and can be used to give information about a thrown exception?

A) getInfo
B) printInfo
C) printStackTrace
D) getStackTrace
E) none of the above
سؤال
The Exception class is a subclass of the Object class.
سؤال
A(n) ____________________ is used to specify how certain exceptions should be handled.

A) finally block
B) try block
C) catch block
D) error
E) none of the above
سؤال
What is a catch clause?
سؤال
The getMessage method of the Exception class prints out the stack trace, which helps the user to track down the source of the exception.
سؤال
When accessing an element of an array, if the index is outside of the range of the indexes of the array, an exception is thrown.
سؤال
What are the standard I/O streams?
سؤال
Is the Exception class a subclass of the Error class? Explain.
سؤال
A throw statement is used to begin exception propagation.
سؤال
Write a short snippet of code that converts the first element of the String[] args array to an integer. It should catch an exception and print out a message if the first element cannot be converted to an integer.
سؤال
Consider the following code fragment.
String s;
for(int i = 0; i < s.length(); i++)
System.out.println(s.charAt(i));
What exception will be thrown by this code and why?
سؤال
What is exception prorogation, and how does it work in Java?
سؤال
What is the difference between a checked exception and an unchecked exception?
سؤال
Give two examples of methods in the Exception class that can be used to output information about the Exception.
سؤال
Consider the following code fragment.
int [] a = new int[50];
a[50] = 100;
Will this code fragment throw an exception? Explain.
سؤال
Write a code fragment that will throw an ArithmeticException. Your code fragment should not use the throw statement.
سؤال
How is a finally clause different from a try block and a catch clause?
سؤال
What is a try block?
سؤال
In practice, it is important to catch all exceptions that might be thrown by a program.
سؤال
How does a method throw an exception?
سؤال
Is an exception an object? Explain.
سؤال
What is the difference between an exception and an error?
سؤال
An exception will be propagated until it is caught and handled or until it is passed out of the main method.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 10: Exceptions
1
Which of the following exceptions are unchecked?

A) RuntimeException
B) IllegalAccessException
C) NoSuchMethodException
D) ClassNotFoundException
E) none of the above
A
Explanation: All subclasses of the RuntimeException class are unchecked.
2
Every line in a catch block is guaranteed to be executed in all situations.
False
Explanation: A catch block may not be executed at all. It is only executed when an exception is thrown. All lines in a finally block are guaranteed to be executed.
3
A(n) ____________________ can be used to find the exact line where an exception was thrown during program execution.

A) interface
B) call-stack trace
C) try block
D) catch block
E) none of the above
B
Explanation: A call-stack indicates the exact line where an exception is thrown.
4
Which of the following represents the standard input stream?

A) System.in
B) System.out
C) System.err
D) System.instream
E) System.outstream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
A(n) _____________________ is an object that defines an unusual or erroneous situation that is typically recoverable.

A) error
B) exception
C) interface
D) try block
E) catch block
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
A(n) ________________ is an ordered sequence of bytes.

A) exception
B) error
C) input-output flow
D) stream
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
A(n) ____________________ is used to identify a block of statements that may cause an exception.

A) call-stack trace
B) error
C) catch block
D) try block
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which of the following file streams should be explicitly closed to ensure that written data is properly retained?

A) output
B) input
C) error
D) writable
E) readable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which of the following exception types must always be caught unless they are contained in methods that throw them in the method header?

A) file stream
B) IO
C) checked
D) unchecked
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
The Exception class and the Error class are subclasses of the ___________________ class.

A) Throwable
B) Catchable
C) RuntimeProblem
D) CompilerProblem
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
Unchecked exceptions must be caught or propogated, or a program will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
The _________________ statement is used to begin exception propogation.

A) propogate
B) relay
C) throw
D) except
E) send
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
Every line of a(n) __________________ is executed no matter what exceptions are thrown.

A) try block
B) call stack trace
C) catch block
D) interface
E) finally block
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
If an exception is not caught, a program will __________________________ .

A) not compile
B) terminate abnormally
C) print a message and continue executing
D) all of the above
E) neither a, b nor c
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
A finally clause is always required in a try-catch block.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
Attempting to divide by zero will result in an Error being thrown, not an Exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
A(n) _____________________ is an object that defines an erroneous situation from which the program usually cannot recover.

A) error
B) exception
C) interface
D) try block
E) catch block
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following methods are part of the Exception class and can be used to give information about a thrown exception?

A) getInfo
B) printInfo
C) printStackTrace
D) getStackTrace
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
The Exception class is a subclass of the Object class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
A(n) ____________________ is used to specify how certain exceptions should be handled.

A) finally block
B) try block
C) catch block
D) error
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
What is a catch clause?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
The getMessage method of the Exception class prints out the stack trace, which helps the user to track down the source of the exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
When accessing an element of an array, if the index is outside of the range of the indexes of the array, an exception is thrown.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
What are the standard I/O streams?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
Is the Exception class a subclass of the Error class? Explain.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
A throw statement is used to begin exception propagation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
Write a short snippet of code that converts the first element of the String[] args array to an integer. It should catch an exception and print out a message if the first element cannot be converted to an integer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
Consider the following code fragment.
String s;
for(int i = 0; i < s.length(); i++)
System.out.println(s.charAt(i));
What exception will be thrown by this code and why?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
What is exception prorogation, and how does it work in Java?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
What is the difference between a checked exception and an unchecked exception?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
Give two examples of methods in the Exception class that can be used to output information about the Exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
Consider the following code fragment.
int [] a = new int[50];
a[50] = 100;
Will this code fragment throw an exception? Explain.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
Write a code fragment that will throw an ArithmeticException. Your code fragment should not use the throw statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
How is a finally clause different from a try block and a catch clause?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
What is a try block?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
In practice, it is important to catch all exceptions that might be thrown by a program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
How does a method throw an exception?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
Is an exception an object? Explain.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
What is the difference between an exception and an error?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
An exception will be propagated until it is caught and handled or until it is passed out of the main method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.