|
Can Abstract Class have constructors?
Answer Description: Abstract class can have a constructor, but we can’t access it through the object, since we cannot instantiate abstract class. To access the constructor first create a sub class and then extend the abstract class which is having the constructor.Example public abstract class ExampleAbstract { public ExampleAbstract(){ System.out.println("In ExampleAbstract()"); } }public class Test extends ExampleAbstract{ public static void main(String args[]){ Test obj=new Test(); } }
Posted By:de_23@...
View Count:
|
|