119k views
1 vote
When an unchecked exception occurs in a method but is not caught:

a. the method-call stack is "unwound."
b. the method terminates.
c. all local variables in that method go out of scope.
d. All of the above.

User Marpme
by
8.3k points

1 Answer

0 votes

Final answer:

When an unchecked exception occurs and is not caught, the method-call stack is unwound, the method terminates, and local variables go out of scope, which accounts for all the options provided.

Step-by-step explanation:

When an unchecked exception occurs in a method and it is not caught, the result is d. All of the above. This implies that the method-call stack is indeed 'unwound', meaning that the method in which the exception occurred will terminate, and control flow will proceed to the previous method in the call stack to see if the exception is caught there.

If not, the unwinding continues until the exception is caught or it reaches the bottom of the call stack, which could result in the termination of the program if it remains unhandled. During this process, as the method terminates, all local variables in that method do indeed go out of scope and are no longer accessible.

User Detmar
by
7.6k points