Search Interview Questions
| 3193 questions in repository.|
There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Java - Interview Questions and Answers|
|Frequently asked in Infosys and HCL Technologies ( Based on 2 feedback )|
|Ans. Using new operator - new xyzClass()|
Using factory methods - xyzFactory.getInstance( )
Using newInstance( ) method - (Class.forName(xyzClass))emp.newInstance( )
By cloning an already available object - (xyzClass)obj1.clone( )
Sample Code for object initialization using clone
Sample Code for object initialization using getInstance
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve java oops object creation new operator class.forname cloning ebay Intelligrape Infosys Polaris British Telecom (BT) Vyom Labs Deutsche Bank HCL Technologies Genpact Thomson Reuters expert|
|Describe what happens when an object is created in Java ?|
|Does Constructor creates the object ?|
|Difference between new operator and Class.forName().newInstance() ?|
|Difference between Class#getInstance() and new operator ?|
|In a case where there are no instance variables what does the default constructor initialize?|
|How can we prevent duplicate object creation in Java?|