Yes, we can declare an abstract class without 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(); } }
In the above example, we did not define the abstract method in the AbstractDemo class. The compiler will not throw any compile-time errors.
Welcome to Tutorials Point
The above is the detailed content of In Java, can we define an abstract class without abstract methods?. For more information, please follow other related articles on the PHP Chinese website!