Core Java - Interview Questions and Answers for 'Instantiation' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 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.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Instantiation' - 3 question(s) found - Order By Newest

 Q1. What is the difference between declaration, instantiation and initialization ?Core Java
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 :   

   Like         Discuss         Correct / Improve     declaration   instantiation   initialization   construction   declaration vs instantiation   instantiation vs initialization   declaration vs initialization     Asked in 1 Companies      basic        frequent


Related Questions

  What are the common uses of "this" keyword in java ?
  Can we use both "this()" and "super()" in a constructor ?
  Why every object constructor automatically call super() in Object before its own constructors?
  Does Constructor creates the object ?
  Can constructors be synchronized in Java ?
 What are constructors and Destructors in Java ?
  Are constructors inherited? Can a subclass call the parent's class constructor? When?
  Difference between object instantiation and construction ?
  How can we create objects if we make the constructor private ?
  Difference Between this() and super() ?


 Q2. Difference between object instantiation and construction ?Core Java
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 :   

   Like         Discuss         Correct / Improve     java   oops   constructor   object instantiation


Related Questions

  What are the common uses of "this" keyword in java ?
  Can we use both "this()" and "super()" in a constructor ?
  Why every object constructor automatically call super() in Object before its own constructors?
  Does Constructor creates the object ?
  Can constructors be synchronized in Java ?
 What are constructors and Destructors in Java ?
  Are constructors inherited? Can a subclass call the parent's class constructor? When?
  How can we create objects if we make the constructor private ?
  Difference Between this() and super() ?


 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 :   

   Like         Discuss         Correct / Improve     java   oops   object instantiation   object creation   class.forname   newinstance   new operator   difference between   advanced      intermediate


Related Questions

  Difference between == and .equals() ?
  Explain the scenerios to choose between String , StringBuilder and StringBuffer ?

or

What is the difference between String , StringBuilder and StringBuffer ?
  What are the difference between composition and inheritance in Java?
  What is the difference between final, finally and finalize() ?
  What is the difference between Encapsulation and Abstraction?
 What is the difference between declaration, instantiation and initialization ?
  What is the difference between ArrayList and LinkedList ?
 If you are given a choice to use either ArrayList and LinkedList, Which one would you use and Why ?
  Difference between final and effectively final ? Why is effectively final even required ?
  Difference between Overloading and Overriding ?



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: