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. |
|
| ||||
Core Java - Interview Questions and Answers for 'Object instantiation' - 2 question(s) found - Order By Newest | ||||
| ||||
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? | ||||
Can constructors be synchronized in Java ? | ||||
Does Constructor creates the object ? | ||||
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() ? | ||||
| ||||
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 ArrayList and LinkedList ? | ||||
What is the difference between declaration, instantiation and initialization ? | ||||
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 ? | ||||