abstract member function java code example

Example 1: how to create an abstract method in java

abstract class Scratch{
  // cannot be static
    abstract public void hello();
    abstract String randNum();
}

interface Other{
  //all methods in an interface are abstract
    public void bye();
    String randDouble();
}

Example 2: can abstract class have implementation java

abstract classes have no implementation of functions methods inside it which declared as abstract methods. classes which are inheriting it have to overriden it. and final absract class can not be overriden

Tags:

Java Example