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 an abstract class have a constructor?



Can an abstract class have a constructor?..

Answer / jag bhushan

yes,
we can have constructor in abstract class.
But we can not make instance of the abstract class.
instead we can make a reference to that abstract class.
and when we make a new object of the class which extends
the abstract class, the constructor of abstract class get
called.

see the code for example:

public abstract class TestAbstract {

TestAbstract(){

System.out.println("...in abstract class'
constructor");
}

public abstract void showAbstract();
public void show(){
System.out.println("...in show");
}
}


public class Test extends TestAbstract{
public static void main(String[] args) {

TestAbstract ta = new Test(); // onstructor
call
ta.showAbstract();
ta.show();

}

public void showAbstract() {
System.out.println("...in showAbstract");

}

}

Is This Answer Correct ?    70 Yes 2 No

Post New Answer

More Core Java Interview Questions

Can a variable be local and static at the same time?

0 Answers  


what is session in java?

0 Answers   Seventhsense Technologies,


What are different types of multitasking?

0 Answers  


What is the size of arraylist in java?

0 Answers  


How do you represent a space in regex java?

0 Answers  


Java Compiler is stored in JDK, JRE or JVM?

0 Answers  


How is it possible for two string objects with identical values not to be equal under the == operator?

0 Answers  


How can we make sure main() is the last thread to finish in java program?

0 Answers  


What code optimizations techniques you follow in general practice?

2 Answers   Accenture, TCS, Wipro,


Can Applet have constructors?

5 Answers   Infosys,


How to solve the problem of generating the unique hash keys with hash function?

0 Answers  


What is a text string?

0 Answers  


Categories