Actually, it won't be able to invoke the pop_test() method i suppose.
If you see this part of code.
It says that inside class Test, declare a reference variable of type Annonymous, then declare a new class that has no name but is the
subclass of Anonymous. The whole point to declare such classes is to override the methods of the super-class that is Anonymous.
It should be noted that you are using a super-class reference to refer to the sub-class object. There are potential limitations to this.
You can only call those methods on an anonymous inner class that are defined the reference variable type.
Spot the problem here, in this anonymous class, rather then overriding the method you are declaring a new method called pop_test,
but the reference type is of Super class and super class won't know anything about this method. That is a potential limitation in this case.
It isn't clear to me where exactly you intend to call the pop_test method. But you can call it like this:
Just call the method by adding ".pop_test()" to the end of the anonymous class declaration. In this case you can't really assign the new Anonymous class to a reference since the pop_test method returns void. You are just instantiating it and calling the pop_test() method along with it. All in one if that is what you want.