HI.
class
Test {
static void show() {
System.out.println("Show method in Test class");
}
}
public class Q2 extends Test
{ static void show()
{
System.out.println("Show method in Q2 class");
}
public static void main(
String[] args)
{
Test t = new Test();
t.show();
Q2 q = new Q2();
q.show();
t = q;
t.show();
q = (Q2)t;//1
q.show();
}
}
when i run this o/p is
prints "Show method in Test class"...1
"Show method in Q2 class".....2
"Show method in Test class"...3
"Show method in Q2 class".....4
actually i expected runtime exception at //1..
what im missing ? pls help.
regards
Jaya Murugan