1
JavaAdvanced#jvm
Fields are resolved statically based on the declared reference type (no polymorphism for fields), so obj.x accesses Base's x = 10. Methods are resolved dynamically based on the actual object type (polymorphism), so obj.getX() calls Derived's override, returning 20.
Base obj = new Derived(); System.out.println(obj.x); // 10 (field access is static) System.out.println(obj.getX()); // 20 (method call is dynamic/polymorphic)