26.  What is the output of this program ?
class exception_handling {
public static void main(String args[]) {
try {
int i, sum;
sum = 10;
for (i = -1; i < 3 ;++i) {
sum = (sum / i);
System.out.print(i);
}
}
catch(ArithmeticException e) {
System.out.print(‘’0’’);
}
}
}


-1
0.
-10
-101


Answer

 Option

No answer description available for this question.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

27.  Which of these keywords must be used to handle the exception thrown by try block in some rational manner ?


try
finally
throw
catch


Answer

 Option

If an exception occurs within the try block, it is thrown and cached by catch block for processing.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

28.  What is the output of this program ?
class exception_handling {
public static void main(String args[]) {
try {
int a, b;
b = 0;
a = 5 / b;
System.out.print(‘’A’’);
}
catch(ArithmeticException e) {
System.out.print(‘’B’’);
}
finally {
System.out.print(‘’C’’);
}
}
}


A
B
AC
BC


Answer

 Option

finally keyword is used to execute the code before try and catch block end.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

29.  When does Exceptions in java arises in code sequence ?


Run time
Compilation Time
Can Occur Any Time
None of the mentioned


Answer

 Option

Exceptions in java are run-time errors.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

30.  Which of these keywords is not a part of exception handling ?


try
finally
thrown
catch


Answer

 Option

Exceptional handling is managed via 5 keywords – try, catch, throws, throw and finally.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report