Only for the first item - you can consider the answer below and to implement the implementation of the subclass it can be abstract, but the call to the general functionality of the code can occur if the base class has some implementation.
The return type can be an object in the base class and return null. In SubClass, a specific return type can be specified below.
public class InheritanceTutorial { static class Base{ public Object doSomething(){ System.out.println("parent dosomething"); return null; } } static class SubClass extends Base{ public Integer doSomething(){ super.doSomething(); System.out.println("child dosomething"); return 0; } } public static void main(String[] args) { SubClass subClass = new SubClass(); subClass.doSomething(); } }
source share