aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Eception Issue.......... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Eception Issue.........." Watch "Eception Issue.........." New topic
Author

Eception Issue..........

deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
class A {
public static void main (String[] args) {
Object error = new Error();
Object runtimeException = new RuntimeException();
System.out.print((error instanceof Exception) + ",");
System.out.print(runtimeException instanceof Exception);
}}

Hi
Can you Explain me about Statement....
Object error = new Error();

Here Error class is a Direct Subclass of Throwable.....So how can Object be the Superclass of Error...


Thanks in Advance....
Deepak
Timmy Marks
Ranch Hand

Joined: Dec 01, 2003
Posts: 226
Error class is a Direct Subclass of Throwable


Which is a subclass of ...?
deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
Timmy
Can you tell me the Hierarchy...
S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
Deepu

This is the hierarchy...

java.lang.Object
|
java.lang.Throwable
|
java.lang.Error


So regardless of whatever the class be, they are the subclass of Object in java. So you can assign object of any class to the reference holder of type java.lang.Object. Clear?


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, NEXT--->IBM XML
Timmy Marks
Ranch Hand

Joined: Dec 01, 2003
Posts: 226
from the javadoc:

java.lang
Class Error
java.lang.Object
java.lang.Throwable
java.lang.Error


Google can be your friend.
deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
Thanks guys....
soumya ravindranath
Ranch Hand

Joined: Jan 26, 2001
Posts: 300
Deepu,

I find it very helpful to have a local copy of the Java API in HTML form. You can easily download it from J2SE API.

Soumya
 
jQuery in Action, 2nd edition
 
subject: Eception Issue..........