What is the result of compiling and running the following code (check all that apply)?

class ADaemon implements Runnable {
    public void run() {
        try {
            System.out.println("Running ADaemon");
        } catch (InterruptedException e) {
            System.out.println("Exiting with InterruptedException");
        } finally {
            System.out.println("Should this run in any case?");

public class DaemonsDontRunFinally {
    public static void main(String[] args) {
        Thread t = new Thread(new ADaemon());
All daemons are stopped "suddenly" when the last non-daemon stops. Thus after finishing execution of main() JVM immediately interrupts all daemons without following any formal rules.
If daemon was interrupted during a try-block, finally-block could have not been executed.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Зарегистрируйся сейчас
или Подпишись на будущие тесты