Exception handling catch block?
Please observe the following code....
public class MyClass
{
public static void main(String[] args)
{
try{
//code here
}catch(Exception e)
{
System.out.println(e);
}
}
}
if the try block throws an ArithmeticException,NullPointerException,etc....
we can handle the exception...Because those are the sub classes of Exception class...
The Question is if we write catch block like this what happened...
try{
//code here
}catch(Object obj)
{
system.out.println(obj);
}
here for Object class is the super class for all the classes in java....
why can't we assign the any exception class object to the reference of Object class in catch block....
please give me a proper answer?
Questions by sivakumar.java answers by sivakumar.java
Showing Answers 1 - 1 of 1 Answers
Related Answered Questions
Related Open Questions
Exception handling catch block?
public class MyClass
{
public static void main(String[] args)
{
try{
//code here
}catch(Exception e)
{
System.out.println(e);
}
}
}
if the try block throws an ArithmeticException,NullPointerException,etc....
we can handle the exception...Because those are the sub classes of Exception class...
The Question is if we write catch block like this what happened...
try{
//code here
}catch(Object obj)
{
system.out.println(obj);
}
here for Object class is the super class for all the classes in java....
why can't we assign the any exception class object to the reference of Object class in catch block....
please give me a proper answer?
Profile Answers by sivakumar.java Questions by sivakumar.java
Questions by sivakumar.java answers by sivakumar.java
Related Answered Questions
Related Open Questions