class A
{
void sayHello()
{
System.out.println("Parent speaking");
}
void getname()
{
sayHello();
}
}
class B extends A
{
@Override
void sayHello()
{
System.out.println("child speaking");
}
}
public class C extends B
{
public static void main(String[] args)
{
B b = new B();
b.getname();
}
}
What will be the output ?
child speaking
ReplyDeletewill be the output
:)
Child speaking is correct...
ReplyDeletethe reference variable b holds the reference to object of class B ...so at run time it will call method of class B...