Implementing error handling for division by zero operation

Report a typo

You are presented a chunk of Java code where you should implement some error handling logic. You need to fill the blanks in code in order to make it effectively handle an ArithmeticException - caused by a division by zero operation - by logging the error message to the console. Your solution must utilize the logging system provided in the program. Consider the hierarchy of exceptions and the error message before making a choice.

Fill in the gaps with the relevant elements
import java.util.logging.Logger;

public class Main {
    private static final Logger LOGGER = Logger.getLogger(Main.class.getName());

    public static void main(String[] args) {
         {
            int result = 10 / 0;
        }  ( e) {
            ("Caught an ArithmeticException: " + e.getMessage());
        }
    }
}
catchArithmeticExceptionLOGGER.severetry
___

Create a free account to access the full topic