Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to override only required abstract methods in interface or Abstract classes among n-methods?

Tags:

java

Is it possible to override only some abstract methods in interface among set of abstract methods?

like image 395
Raj Avatar asked Dec 05 '25 01:12

Raj


2 Answers

Yes you can provided you make that class also as abstract.

like image 72
adarshr Avatar answered Dec 07 '25 16:12

adarshr


Is it possible to override only some abstract methods in interface

Yes, but since the resulting class is still not fully concrete, this class has to be declared abstract.

This compiles fine:

interface MyInterface {
    void method1();
    void method2();
}

abstract class MyClass implements MyInterface {
    public void method1() { }
}

(but it won't compile without the abstract modifier).

like image 25
aioobe Avatar answered Dec 07 '25 16:12

aioobe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!