Which of the following is not true regarding the point at which an Exception is
ID: 644500 • Letter: W
Question
Which of the following is not true regarding the point at which an Exception is thrown?
Question 3 options:
An exception can be declared and created at a different place in the program from the point at which it is thrown.
A) It specifies the point at which the exception must be handled. B)An exception can be declared and created at a different place in the program from the point at which it is thrown.
C) It is the initial point at which the exception occurs. D) The throw point is listed in the first row of the stack trace if the stack trace of an Exception is printed.Explanation / Answer
C)It is the initial point at which the exception occurs.
When a program violates the semantic constraints of the Java programming language, the Java virtual machine signals this error to the program as anexception. An example of such a violation is an attempt to index outside the bounds of an array. Some programming languages and their implementations react to such errors by peremptorily terminating the program; other programming languages allow an implementation to react in an arbitrary or unpredictable way. Neither of these approaches is compatible with the design goals of the Java platform: to provide portability and robustness. Instead, the Java programming language specifies that an exception will be thrown when semantic constraints are violated and will cause a non-local transfer of control from the point where the exception occurred to a point that can be specified by the programmer. An exception is said to be thrown from the point where it occurred and is said to be caught at the point to which control is transferred.
Explicit use of throw statements provides an alternative to the old-fashioned style of handling error conditions by returning funny values, such as the integer value -1 where a negative value would not normally be expected. Experience shows that too often such funny values are ignored or not checked for by callers, leading to programs that are not robust, exhibit undesirable behavior, or both.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.