- Scanner Input New Scanner System In Int Waittime Try System Out Println Start Of The Try Block System Out Prin 1 (153.72 KiB) Viewed 10 times
Scanner input = new Scanner(System.in); int waitTime; try{ System.out.println("Start of the try block"); System.out.prin
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Scanner input = new Scanner(System.in); int waitTime; try{ System.out.println("Start of the try block"); System.out.prin
Scanner input = new Scanner(System.in); int waitTime; try{ System.out.println("Start of the try block"); System.out.println("Enter the time in sec. !!"); waitTime = input.nextInt(); if (waitTime > 30) { throw new Exception ("Time Limit Exceeded"); } System.out.println("End of try block"); } catch(Exception e) { System.out.println("Exception: "+e.getMessage()); } System.out.println("End of the program !!"); 21 } 22 } a) Guess the output of the above program if inputs are 31 and 30. Also, Justify your answer. 18 19 20 15 14 345 16 17 ▼ 10 11 12 ▼ 13 8 9 Upload answer sheets Consider the code below: 1 import java.util.Scanner; 2v class CatQuestion{ 3 public static void main(String[] args) 4▼ { 5 6 7▼