Winston Gutkowski wrote:
Change AnonymousClsDemo to define:
public final void eat() { ...
but you can't have eat method in anonymous class because final method can't be overridden.
Yes
Change 'obj's implementation to:
public void eat() {
super.eat();
}
This works as it calls eat method of AnonymousClsDemo as AnonymousClsDemo is super class of anonymous subclass. Like this
Output:
Eating Outer
Eating Inner
Another way is by making AnonymousClsDemo eat method access modifier as private.
Output: Eating Outer