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 void keyword?

1051


Explain the use of shift operator in java. Can you give some examples?

925


What are access specifiers in java ?

1068


Can constructor be inherited?

985


Can we return null in java?

1077


what is meant by Garbage collection?

1046


What is an enumeration?

1012


Is java an ide?

929


What are the basic control structures?

937


How will you load a specific locale?

933


What is hash in java?

913


What is replaceall in java?

980


Is it possible to override the main method?

933


What do you understand by access specifiers in Java?

970


why an outer class cannot be declared as private?

4232