Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can you have a constructor in abstract class?

Answer Posted / vinoth kumar

Yes,
we can define it in the abstract class itself.But it invoke
only by super() in sub class constructor.

Example:

abstract class AbsConstCheck{
AbsConstCheck(){
System.out.println("I AM WORKING AbsConstCheck");
}//some other methods declaration
}
class Sub extends AbsConstCheck{
sub(){
super();//calling abstract class constructor
System.out.println("I AM WORKING Sub");
}
}
class Main{
public static void main(String vin[]){
Sub s=new Sub();//calling sub,abstract class constructor
}
}

Output:

I AM WORKING AbsConstCheck
I AM WORKING Sub

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a treeset in java?

989


What is the SimpleTimeZone class?

2207


What are the states of thread in java?

918


Why do we use variables?

926


Why java is a platform independent? Explain

1005


What are the features of java?

1007


Write a program to calculate factorial in java?

954


give an example for encapsulation?

986


Why you should not use singleton?

918


Is null a value?

970


What is e in java?

908


Can I learn java without any programming experience?

980


How will you reverse a singly-link list?

938


Can private method static?

865


In java, how many ways you can take input from the console?

930