Hi Ganga,
Observe the following code.
Throwable t = new Exception(); //1
Exception e = new Throwable(); //2
For sure the stmt marked //1 will compile.Do u think //2 also will get compiled?.No it'll never.Casting pblm comes into picture now..which forces the compiler to check the rule u stated in ur post!.
Lets say if u have stmts like this..
Test t = new TestIt();
t.method1();
For hypothetical situation assume the method1 is allowed to throw Throwable(in child class) & Exception(in parent class).Consider the following code for the same.(Surely it wont work..
)
Now consider what if the above snippet runs from the main method???!!!
Ouch..JVM will throw classCastException!!!
Coz it is obvious it cant wrap Throwable object in Exception Reference type.
Compiler is smart enough to identify & prevent these kind of situations!!.
hth..
Regards,
Priya.