Organizational Research By

Surprising Reserch Topic

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("way2java.com"); 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
26 views



Related Hot Questions



Government Jobs Opening


...