adplus-dvertising
frame-decoration

Question

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");
            }
        }
    }

a.

-1

b.

0

c.

-10

d.

-101

Posted under Java Programming

Answer: (c).-10

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?