A class containing abstract methods must be an abstract class java code example

Example 1: can abstract class have non abstract methods in java

abstract class AbstractDemo { // Abstract class
   private int i = 0;
   public void display() { // non-abstract method
      System.out.print("Welcome to Tutorials Point");
   }
}
public class InheritedClassDemo extends AbstractDemo {
   public static void main(String args[]) {
      AbstractDemo demo = new InheritedClassDemo();
      demo.display();
   }
}

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:

Misc Example