Can an Abstract class non abstract method be overridden by using Anonymous class?. The FindBugs tool is issuing " Uncallable method of anonymous class" issue. Please check the below example for more information
public class BaseClass {
// This class is a Library Class.
}
public abstract class AbstractBaseClass extends BaseClass {
public abstract void abstractMethod();
public void nonAbstractMethod() {}
}
public abstract class DerivedAbstractClass extends AbstractBaseClass {
// Here Some more additional methods has been added
}
public class DemoAbstract {
public static void main(String[] args) {
init();
}
private static void init() {
DerivedAbstractClass derivedAbstractClass = new DerivedAbstractClass() {
@Override
public void abstractMethod() {
}
@Override
public void nonAbstractMethod() {
// Is it possible to override like this?
}
};
}
}
Yes, this is possible. You can override any non final, non static method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With