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 {
-
public static void main(String[] args) {
-
int n = 0, mark=0 ;
-
float avg=0;
-
Scanner input = new Scanner(_______________);
-
System.out.print("Enter number of subjects and mark ");
-
try {
n = input.nextInt(); mark = input.nextInt(); avg = mark / n;
-
}
-
catch(______________________________________) {
-
System.out.print("Enter only integer number for n and mark"); }
-
catch(______________________________________) {
-
System.out.print("denominator cannot be zero"); }
-
a) Identify the missing import statement at Line 1.
-
b) Fill the missing statement at Line 5.
-
c) Identify the exception which will catch the wrong data input at Line 9.
-
d) Identify the exception which will catch the divide by zero error at Line 11.
-
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.
-
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started