Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
deepu Bhalotia
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Error class is a Direct Subclass of Throwable


Which is a subclass of ...?
 
deepu Bhalotia
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Timmy
Can you tell me the Hierarchy...
 
S.L.Narayanan
Ranch Hand
Posts: 431
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Timmy Marks
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys....
 
soumya ravindranath
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic