Can an abstract class have a constructor?

Yes, it can have and moreover can be overloaded as constructor is special type of method where return type is missing (and class name and constructor name should be same). Following program compiles successfully and executes happily. abstract class Test { public Test() { this(""); System.out.println("Abstract class default constructor"); } public Test(String str) { System.out.println("My name is " + str); } } public class Demo extends Test { public static void main(String args[]) { new Demo(); } }

asked Sep 13, 2013 in Core java by itkbc
edited Sep 12, 2013
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.