Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


if u can possible create the constructor in abstract class?


Advertisement
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();
    }
}


Related Tutorials/Questions & Answers:
Advertisements
open taps CRM
open taps CRM  hi Plese guide to me how to forecase in Java Ofbiz Opentaps CRM Module Thanks hasim
Advertisements
 

 

 

DMCA.com