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(Myexception e)
           {
               System.out.print("Exception");
           } 
        }
    }

a.

3

b.

Exception

c.

Runtime Error

d.

Compilation Error

Answer: (b).Exception

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?