If I am wrong, the default methods are virtual in java, so you override the method correctly. However, fields (for example, "x") are not virtual and cannot be overridden. When you declare "int x" in B, you are actually creating a completely new variable.
Polymorphism does not take effect for fields, so when you try to extract x on an object cast to type A, you will get 5, if the object is distinguished to type B, you will get 6.
source share