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 call a constructor within a constructor?

Answer Posted / ranganathkini

Yes once constructor can call another constructor by using
the this() statement. Example:

class Account {
private double balance;

// 1st Constructor
public Account( double initBalance ) {
balance = initBalance;
}

// 2nd Constructor
public Account() {
this( 0.0 ); // call the 1st constructor
}
}

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a method header?

968


How many java versions are there?

996


what is synchronization? : Java thread

967


What is the applet security manager, and what does it provide?

943


How arrays are stored in memory in java?

921


What is the use of math abs in java?

959


What does the append?

939


What is oop in java?

955


How do you create a method in java?

940


Why do we use return statement?

965


What is scope & storage allocation of global and extern variables? Explain with an example

988


How to implement a multithreaded applet?

2607


Why constructor has no return type?

1052


What is the difference between jvm and jre? What is an interface?

1011


Can we override constructor?

965