Home » JAVA Programming » Exceptions » Question
  1. What is the output of this program?
    class Myexception extends Exception 
    {
    int Execution;
    Myexception(int n)
    {
    Execution = n;
    }
    public String toString()
    {
    return "Execution";
    }
    }

    public class UserDefine_Exception
    {
    static void compute (int n) throws Myexception
    {
    throw new Myexception(n);
    }
    public static void main(String args[])
    {
    try
    {
    compute(5);
    }
    catch(Myexception e)
    {
    System.out.print("User define Exception executed...");
    }
    }
    }
    1. User define Exception executed...
    2. Execution
    3. Compilation Error
    4. Runtime Error
    5. None of these
Correct Option: A

Myexception is self defined exception.



Your comments will be displayed only after manual approval.