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 - 3 of 3 Answers

Raghu

  • Aug 19th, 2011
 

An exception type must be subtype of Throwable class.............

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions