A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/quizzes/java-quiz/exception-handling-2-gq/ below:

Quiz about Java Exception Handling

Which statement about final, finally, and finalize is correct?

Which of the following blocks always executes, regardless of an exception occurring or not?

What will be the output of the following code?

Java
public class Geeks {
    public static void main(String[] args) {
        try {
            System.out.println("Inside try");
            throw new RuntimeException("Error");
        } finally {
            System.out.println("Inside finally");
        }
    }
}

What will happen in the following code?

Java
public class Geeks {
    static void method() throws Exception {
        throw new Exception("Error occurred");
    }

    public static void main(String[] args) {
        method();
    }
}

What is the difference between throw and throws?

What will be the output of the following program?

Java
class CustomException extends Exception {
    public CustomException(String message) {
        super(message);
    }
}

public class Geeks {
    public static void main(String[] args) {
        try {
            throw new CustomException("Custom error occurred");
        } catch (CustomException e) {
            System.out.println(e.getMessage());
        }
    }
}

What happens when finalize() is called on an object?

What is the output of the following code?

Java
public class Geeks {
    public static void main(String[] args) {
        try {
            System.exit(0);
        } finally {
            System.out.println("Finally executed");
        }
    }
}

Which of the following is true about custom exceptions?

Which of the following correctly defines a custom exception?

There are 10 questions to complete.

Take a part in the ongoing discussion


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4