More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. Declaration is intimation to the compiler about the nature of Data a reference is going to hold.
For example - List myList;
Instantiation is reservation of memory.
For example
myList = new ArrayList();
Initialization or construction is setting the default values for member elements.
For example
myList = new ArrayList(mySet);
** Example 2nd is both for instantiation as well as initialization. The only difference is that 2nd will initialized the member elements to their default values whereas 3rd will initialized it with the elements from set.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  declaration   instantiation   initialization   construction   declaration vs instantiation   instantiation vs initialization   declaration vs initialization Asked in 1 Companiesbasic  frequent
Ans. Though It's often confused with each other, Object Creation ( Instantiation ) and Initialization ( Construction ) are different things in Java. Construction follows object creation.
Object Creation is the process to create the object in memory and returning its handler. Java provides New keyword for object creation.
Initialization is the process of setting the initial / default values to the members. Constructor is used for this purpose. If we don't provide any constructor, Java provides one default implementation to set the default values according to the member data types.
Help us improve. Please let us know the company, where you were asked this question :
Q3. Difference between new operator and Class.forName().newInstance() ?
Ans. new operator is used to statically create an instance of object. newInstance() is used to create an object dynamically ( like if the class name needs to be picked from configuration file ). If you know what class needs to be initialized , new is the optimized way of instantiating Class.
Help us improve. Please let us know the company, where you were asked this question :