29. What will happen if you compile and run the following code?
class Test2
{
static void show()
{
System.out.println("Show method in Test class");
}
}
public class Q2 extends Test2
{
static void show()
{
System.out.println("Show method in Q2 class");
}
public static void main(String[] args)
{
Test2 t = new Test2();
t.show();
Q2 q = new Q2();
q.show();
t = q;
t.show();
q = (Q2)t;
q.show();
}
}
Select 1 correct answer:
A. Prints: Show method in Test class
Show method in Q2 class
Show method in Test class
Show method in Q2 class
B. Prints: Show method in Test class
Show method in Q2 class
Show method in Q2 class
Show method in Q2 class
C. Prints: Show method in Test class
Show method in Q2 class
Show method in Test class
Show method in Test class