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

Is java free for commercial?

920


What is the difference between the reader/writer class hierarchy and the inputstream/outputstream class hierarchy in java programming?

1112


Is nan false?

972


Why java is secure? Explain.

1035


Write a program to check for a prime number in java?

1035


What are the elements of java?

1008


What is the difference between abstraction and encapsulation?

1041


What is use of super keyword?

959


Can we override protected method in java?

1051


What is http client in java?

1083


Is a boolean 1 bit?

1060


How variables are stored in memory?

996


Explain where variables are created in memory?

1007


Which is illegal identifier in java?

1081


What is append in java?

1157