Java - Can we have an abstract class without abstract methods ?


Declaring a Class Abstract means that we can't instantiate on its own and is only meant to be sub-classed. Declaring a method abstract means that It's definition will be provided in the sub-class. Both are independent concepts. Yes we can declare a class abstract having no abstract methods. 

For example

public abstract class AbstractClass{

    public void method1(String x){
    }

    public String method2(String x){
    }
}

won't give any compile time or runtime errors.

Why such classes are rarely used ?

These are not widely used due to its impact on run time polymorphism. 

Though we can always override any method in the derived object and hence can use runtime polymorphism but that overriding is optional. In case a particular subclass doesn't override a method , the same definition of the base class will be picked. 

For example

public class DerivedClass extends AbstractClass{
    public String method2(String x){
    }
}

public class DerivedClass2 extends AbstractClass{
    public String method2(String x){
    }
}

In this example both Derived Classes have their own implementation of method2 but are carrying implementation of Method 1 from the base class. If we would have been doing run time polymorphism for method1, It wouldn't have given any polymorphic behavior irrespective of the object.