Core Java - Interview Questions and Answers for 'Class.forname' | 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 'Class.forname' - 2 question(s) found - Order By Newest

Frequently asked in Infosys and HCL Technologies ( Based on 2 feedback )
 Q1. What are different ways of object creation in Java ?Core Java
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     Asked in 9 Companies      expert


Related Questions

  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?


 Q2. 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: