-
What is the output of this program?
class Myexception extends Exception
{
int Execution;
Myexception(int p)
{
Execution = p;
}
public String toString()
{
return "Execution";
}
}
public class Result
{
static void compute (int p) throws Myexception
{
throw new Myexception(p);
}
public static void main(String args[])
{
try
{
compute(6);
}
catch(DevideByZeroException e)
{
System.out.print("Catch block Executed...");
}
}
}
-
- 6
- Compilation Error
- Runtime Error
- Catch block Executed...
- None of these
Correct Option: C
Mexception is self defined exception, we are generating Myexception but catching DevideByZeroException which causes error.
error: cannot find symbol
catch(DevideByZeroException e)
^
symbol: class DevideByZeroException
location: class Result
1 error