// // ExceptionDemo1.java // // P.668, Q1 // import java.util.Scanner; public class ExceptionDemo1 { public static void main(String[] args) { Scanner kb = new Scanner(System.in); System.out.print("Wait time: "); int waitTime = kb.nextInt(); try { System.out.println("Try block entered."); if(waitTime > 30) { Exception e = new Exception("Time limit exceeded."); throw e; } System.out.println("\nLeave try block.\n\n\n"); } catch (Exception e) { System.out.println("\n\nException: " + e.getMessage()); System.out.println("Leave catch block.\n\n\n"); } System.out.println("Byebye"); } }