GeekInterview.com
Series: Subject: Topic:
Question: 10 of 995

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?
Asked by: sivakumar.java | Member Since Jun-2011 | Asked on: Jun 12th, 2011

View all questions by sivakumar.java   View all answers by sivakumar.java

Showing Answers 1 - 1 of 1 Answers
Raghu

Answered On : Aug 19th, 2011

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

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.