Question: Complete the code snippet as per the questions (a) to (f) 1. import ________________________ public class FindQn { public static void main(String[] args) { int

Complete the code snippet as per the questions (a) to (f)

1. import ________________________ public class FindQn {

  1. public static void main(String[] args) {

  2. int n = 0, mark=0 ;

  3. float avg=0;

  4. Scanner input = new Scanner(_______________);

  5. System.out.print("Enter number of subjects and mark ");

  6. try {

    n = input.nextInt(); mark = input.nextInt(); avg = mark / n;

  7. }

  8. catch(______________________________________) {

  9. System.out.print("Enter only integer number for n and mark"); }

  10. catch(______________________________________) {

  11. System.out.print("denominator cannot be zero"); }

  1. a) Identify the missing import statement at Line 1.

  2. b) Fill the missing statement at Line 5.

  3. c) Identify the exception which will catch the wrong data input at Line 9.

  4. d) Identify the exception which will catch the divide by zero error at Line 11.

  5. e) Write the code block after Line 12, which is a block that is used to execute important code such as closing connection, stream etc.

  6. f) In the above try with multicatch statement block, where will you add the following catch block? Justify your answer. catch (Exception e)

{ System.out.print("General Exception"); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!