Why parent class type reference variable having reference to child class object can't access child class's Methods
问题 Since this object(stated in title) can invoke overridden methods in child class, why it can't invoke other methods of child class? I need answer as detailed as possible like memory organization, internal logic in JVM etc. below code will give you clear understanding of my question. class A { int x=10; public A() { System.out.println("Constructor of class A called!!!"); } public void sayGreetings() { System.out.println("accept hye from class A"); } } class C extends A { int x=30;//why this is