can abstract class have constructors in java?

Yes, abstract class have constructors in java. But it is not used to instantiate abstract class. It is used in constructor chaining or to initialize abstract class common variables.

Example:

abstract class DisplayTest {
    protected final String website;
    abstract void display(String str);
 
    DisplayTest(String website){
        this.website = website;
    }
 }
 
public class Main extends DisplayTest
{
    public void display(String str) {
        System.out.println(str + " " + website);
    }
 
    Main(String website){
        super(website);
    }
 
	public static void main(String[] args) {
		DisplayTest displayTest = new Main("w3spoint.com");
		displayTest.display("Hello");
	}
}

Example:

Hello w3spoint.com

Java interview questions on interface and abstract class

Please Share