Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training Big Data and Hadoop Training Java Training  
 

hasim

Ads

 
 

Share on Google+Share on Google+

Moha Hasim Siddiqui
hasim
2 Answer(s)      6 years and 3 months ago
Posted in : Java Interview Questions

if u can possible create the constructor in abstract class?

Ads
View Answers

May 26, 2011 at 5:22 PM


yes, you can have constructor in abstract class.But you cannot make instance of the abstract class. Instead, you can make a reference to that abstract class.

abstract class Test{ abstract void method(); Test(){ System.out.println("Abstract class constructor"); } } public class AbstractClassExample extends Test{ void method(){ } public static void main(String args[]){ Test t= new AbstractClassExample(); } }



May 26, 2011 at 5:22 PM


yes, you can have constructor in abstract class.But you cannot make instance of the abstract class. Instead, you can make a reference to that abstract class.

abstract class Test{
    abstract void method();
    Test(){
        System.out.println("Abstract class constructor");
    }
   }
   public class AbstractClassExample extends Test{
    void method(){
    }
    public static void main(String args[]){
    Test t= new AbstractClassExample();
    }
}

Ads