Throw an unchecked exception

Report a typo

Modify the given method.

It should throw an unchecked exception.

Write a program in Java 17
public class Main {

public static void method() {
// write your code here
}

/* Do not change code below */
public static void main(String[] args) {
try {
method();
} catch (RuntimeException e) {
System.out.println("RuntimeException");
} catch (Exception e) {
System.out.println("Exception");
}
}
}
___

Create a free account to access the full topic