adplus-dvertising
frame-decoration

Question

What is the output of this program?
    class Myexception extends Exception 
    {
 int detail;
        Myexception(int a) 
        {
        detail = a;
 }
 public String toString() 
        {
     return "detail";
 }
    }
    class Output 
    {
        static void compute (int a) throws Myexception
        {
      throw new Myexception(a);  
 }
 public static void main(String args[]) 
        {
            try 
            {
                compute(3);
            }
           catch(DevideByZeroException e)
           {
               System.out.print("Exception");
           } 
        }
    }

a.

3

b.

Exception

c.

Runtime Error

d.

Compilation Error

Posted under Java Programming

Answer: (c).Runtime Error

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?