ExamVeda
Login
Home
This question belongs to Java Program Exceptions
Exceptions
?

What will be the output of the following Java code?
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");
       } 
    }
}

Answer & Solution
Correct Answer: Option B
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.