Topics Index

Arithmetic Exception test

If you need explanation Read this topic

If you need Answer Take test on this topic

Arithmetic Exception test
What will be the output of the following program?
public class Arithmetic {
    private static int y;
    public static void main(String... s) {
        try {
            int x = 0;
            y = 5 / x;
        } catch (ArithmeticException ae) {
            System.out.println("Arithmetic Exception");
        } catch (Exception e) {

A. Arithmetic Exception
B. Arithmetic Exception
C. Exception
D. finished
E. Compilation Error or Runtime Error
Topic: Exception Handling Syntax In Java Programming

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

answer is d exception is cought by first catch..n den the prgm continues its execution..

Posted by Shaik Nyamath    2013-05-23 12:38:14

ans is A as both the exceptions are printed as Arithmetic Exception is printed first and then Exception since it is the superclass of all exceptions !!

Posted by Vinay Reddy    2013-05-23 13:07:16

ans is first checks only the first catch..the exception is handled and prints finished

Posted by Ramya Badisa    2013-05-23 13:26:15

sorry answer is b

Posted by Ramya Badisa    2013-05-23 13:26:43

ANs is B.. since y=5/x where x=0 givs an arthimetic exception.. so first catch function vl catch the exception occured in the try block.. and next finished statement vl be printed...

Posted by Om Prakash Om    2013-05-23 13:32:03

Congratulations Shaik Nyamath. You are today's daily dose winner. Please send us your mobile details and we will recharge tomorrow after considering the new likes.

Posted by Merit Campus    2013-05-23 13:59:05

Got RC ! thnkQ MC :)

Posted by Shaik Nyamath    2013-05-25 14:53:23

© meritcampus 2019

All Rights Reserved.

Open In App