class A
{
}
class B{
void me()
{
System.out.println(“hello you are inside B’s me method”);
}
}
Class C
{
public static void main(String a[])
{
A a=new B();
d.me();
}
}
A
d = new B();
Referencing create a memory for a
object of type B
Here d is a veriable of class A and pointing to a
memory of type class B.
d.me()
here d check the body of me() method inside the A class
wheather it be blank doesn’t metter but it should be .
if it doesn’t
find then it gives error at
compile time.
When program becomes successful compiled then at runtime it
goes to the memory of type B and search there about method me()