This is from Majji -Q2
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;
q.show();
}
}
ans is
C) 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
shouldn't the ans be line 1,2,4,3 bcoz then what is the meaning of assigning t=q ?doesn't t.show now mean q.show?
[This message has been edited by hema janani (edited August 24, 2000).]