Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

The company has fair promotion/advancement policies.

Answered: 1 week ago