Q: Confused about compiler handling inheritance and method invocation After reading some information regarding inheritance and method invocation and how the compiler handles these I got confused.  Therefore I would appreciate it if someone were to take a look at how I see things and correct me where I am wrong.
Let's first take a look at the following code:
Class A:
public class A {

    public void testMethodA(String a) {
        System.out.println(a);
    }

}

Class B:
public class B extends A {


}

Main
public class Main {

    public static void main(String[] args) {
        B b = new B();
        b.testMethodA("test");
    }

}

Now let's take a look at the way I understand things (please correct me if I am wrong):


*

*During inheritance, when creating a subclass object, you are creating one object that receives all the fields and methods from all the superclasses. So the fields and methods of subclasses are not transfered from the superclasses to subclasses during compile time (Source: Does an instance of superclass get created when we instantiate an object?)

*During compile time, the compiler checks if the called to method that supports the argument type is defined in the declared reference type. So in the example: A a = new A(); a.testMethod("test") it would check during compile time if a testMethod() is defined in the class A that can receive a String as argument. (Source: How does java compiler choose correct methods and variables in inheritance)

*When runtime occurs, the testMethod() is invoked from the actual object that is stored in the variable a which is not always an object of type A due to polymorphism.


Now the actual problem:
Based on the logic and code I described above, I expected a Cannot resolve method error during compile time. The reason being is that during compile time the compiler checks class B if testMethodA(String) exists. This is method is however inherited from class A and to my understanding inherited methods are not passed to subclasses but rather to the objects of subclasses during runtime. So if testMethodA(String) doesn't exist in class B during compile time, how can the compiler still compile the code succesfully? Surely it doesn't check the object for the method because that has not been created yet.
This question is not answered in the 'possible answer' as this thread is a thread I myself marked as a source of knowledge when describing this problem. 

A: I think, your main misunderstanding is in point 2.

During compile time, the compiler checks if the called to method that
  supports the argument type is defined in the declared reference type.

This should better read:
During compile time, the compiler checks if the called to method that supports the argument type is defined in the declared reference type or one of its supertypes or implemented interfaces along the whole tree.
The compiler knows that any instance of B (being a subclass of A) will have a method testMethodA(), either the one inherited from the superclass A, or an overridden one from a subclass, so it's safe to call that method.
You use the wording "pass" to describe the inheritance of both fields and methods from a superclass to a subclass. This wording sounds confusing to me, as it implies some duplication process, which only partially takes place. For instance fields, this is more or less ok, as every instance of a subclass will get individual copies of the superclass fields plus the subclass fields. But methods don't get copied to instances, they stay "in" the classes where they were defined (an instance doesn't occupy more memory if you add methods). Internally, the Java Runtime maintains some kind of lookup table to find the appropriate method version for a given instance's class.
So I think, the wording "pass a method to the subclass object" does not fit the actual process.
