Why do you expect "bbb bbb"?
Since you run the instance before a , the only information for the compiler on the first call is the version with "aaa" , so this value is used.
In the second version, without translation, the compiler can see "bbb" , so this value is used.
Polymorphism affects the method that is called - but it does not affect the parameters passed. Essentially, the default values ββare supplied by the compiler (on the call site), so your code is actually equivalent:
((a)new b()).test("aaa"); new b().test("bbb");
where "aaa" and "bbb" provided at compile time , checking the allowed method.
source share