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 / qim2010

Yes, by using this() syntax. E.g.

public Pet(int id) {
this.id = id; // “this” means this object
}
public Pet (int id, String type) {
this(id); // calls constructor public Pet(int id)
this.type = type; // ”this” means this object
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate between static and non-static methods in java.

1094


What is sorting algorithm in java?

1144


What is the integer of 16?

1038


Name some classes present in java.util.regex package.

1070


which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?

11383


What is the best way to findout the time/memory consuming process?

1074


Write a program to print fibonacci series

1235


How to instantiate member inner class?

1143


When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?

1086


What are the states of thread in java?

1033


Why strings in java are called as immutable?

1037


Why does java not support pointers?

1171


What is indexof in java?

1052


Explain thread in java?

1230


What is the purpose of stub and skeleton?

1075