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

Which collection is sorted in java?

1079


What is the difference between static class and normal class?

1084


Can list be null in java?

1097


Write a code to create a trigger to call a stored procedure

1027


What is singleton class and how can we make a class singleton?

1149


Is a boolean 1 bit?

1121


What are the concepts of 'OOPS'?

1115


What is string in java?

1070


What is an example of procedure?

1101


How many arguments can a method have java?

1065


What is comparator in java?

1063


What is the difference between Error, defect,fault, failure and mistake?

1242


What is a substitution variable?

1071


Define jit compiler?

1203


What is treeset and treemap in java?

1137