Write a Java program to show an example of throws Keyword

Source Code:

public class ThrowsExample {
public static void demo() throws InterruptedException {
Thread.sleep(1000);
}

public static void main(String[] args) {
try {
demo();
System.out.println(“Done without error”);
} catch(InterruptedException e) {
System.out.println(“Interrupted error”);
}
}
}

Output: