Yes it is possible!
Cause?
An anonymous class allows you to declare and instantiate a class at the same time, and in your code example this is the line: ( DerivedAbstractClass derivedAbstractClass = new DerivedAbstractClass() ).
Anonymous classes are similar to local classes, except that they do not have a name.
In the snippet below, you extend DerivedAbstractClass and you can implement its abstract methods, and if you want, you can also override a non-abstract method.
But you can call super.nonAbstractMethod(); before overriding, if necessary, as shown below:
DerivedAbstractClass derivedAbstractClass = new DerivedAbstractClass() { @Override public void abstractMethod() {
AADProgramming
source share