Card 09/ 09
All 9 cards
RecapDifficulty: Advanced1 min
What the Compiler Decided, and What the JVM Did
Five things this topic established, and where each one was.
| The thing | Where |
|---|---|
| An overridden method is chosen by the object's class, not the variable's type | One Call, Several Bodies |
| The declared type decides what may be called; the object decides what runs | The Compiler Checks the Reference |
| Fields and static methods are hidden, not overridden, and resolve from the declared type | Why a Field Does Not Override |
| A cast is a promise the compiler accepts and the runtime checks | Why Your Cast Compiled and Then Threw |
| Put the method on the type when types change; use a chain when operations do | A Polymorphic Call Against a Chain of instanceof |
The one worth carrying: exactly one thing in Java is chosen by the object at runtime, and that is an overridden instance method. Fields, static methods and overloads are all chosen earlier, from what the source says the type is.