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

Search Interview Questions


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

   



Core Java - Interview Questions and Answers for 'Cloning' - 15 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
Admin
info@buggybread.com
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


 Q2. What is a cloneable interface and what all methods does it contain?Core Java
Admin
info@buggybread.com
Ans. Cloneable is a declaration that the class implementing it allows cloning or bitwise copy of it's object state. It is not having any method because it is a MARKER interface.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   cloneable   marker interface  cloning     ADP


 Q3. Name few classes that implement Cloneable interface ?
Admin
info@buggybread.com
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_58.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   cloneable  cloning


 Q4. Why do we use a copy constructor ?2016-07-21 08:28:52

Ans. Copy Constructor is used for creating a duplicate of another object. Duplicate object will have the same state of the copied object but will have independent values in different memory locations. Copy Constructor can be useful to create duplicates of immutable objects as the Original cannot be tampered. Moreover It can be useful if base copies are required for individual requests in threading.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     copy constructor  clone  cloning object   immutable  immutability  immutability


 Q5. Does it make sense to clone an object which is supposed to be immutable ?Design2016-07-28 20:54:59

Ans. It make sense only if we intend to modify either of the object and would like to preserve original state in other. Otherwise we can reuse the original object by making it singleton.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     clone  clone objects  prototype design pattern   immutable  immutability  immutability  cloning


 Q6. Why Collection interface does not extend Cloneable interface ?Core Java2016-09-15 09:40:06

Ans. Here is the list of classes that implements Collections Interface - http://www.buggybread.com/2015/02/java-collections-classes-that-implement.html

Having Collection interface to extend Cloneable interface would mean necessarily implement clone method by all implementing classes. As not all collection classes allow duplicate elements, it makes no sense to clone elements for them.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     cloneable  collections  collection interface  cloning


Frequently asked Design Pattern interview question.
 Q7. What is a prototype design pattern ?Design2016-11-04 08:06:01

Ans. The prototype pattern is a creational design pattern. It is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. Prototype is used when we need duplicate copies of objects.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     design pattern  prototype design pattern  cloning     CapitalOne  Orion Edutech  Harris  Myntra  Tata Consultancy (TCS)  HCL Technologies  Infosys  Wipro  Tech Mahindra  IBM  Mahindra Satyam      intermediate


 Q8. Difference between shallow copy and object cloning ?Core Java2017-01-12 14:21:02

Ans. Shallow copy is one of the way for object cloning, other being deep copy.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     cloning  shallow copy  object cloning      basic


 Q9. What is cloning in GIT ?GIT2017-02-08 12:39:40

Ans. Cloning is the process of making a copy. It could be creating local copy of another local repository or local copy of remote repository.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     GIT  Configuration Management  GIT Cloning



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. What is object cloning ?Core Java2017-12-26 09:47:42

 This question was recently asked at 'Genpact'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     cloning     Genpact      basic        frequent


 Q11. Why the singleton class should never implement Cloneable interface ?Design2018-04-08 11:28:54

Ans. Because Singleton implementation doesn't restrict it from cloning and hence we can have multiple objects when we actually don't intend it to have multiple objects.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     singleton  cloning


 Q12. Tell about shallow and deep cloning ?Core Java2018-06-08 19:15:52

 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     cloning


 Q13. Design a Program to clone an object and all it's children.
Design2018-06-13 07:42:57

 This question was recently asked at 'Bloomberg'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     code  coding  cloning  design pattern   cloning design pattern     Bloomberg


 Q14. How to avoid cloning, serialization in the singleton class ?Design2019-01-04 10:12:26

 This question was recently asked at 'Cognizant (CTS)'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     singleton  cloneable  serializable  serialization  cloning     Cognizant (CTS)


 Q15. Explain CloneNotSupportedException ?Core Java2019-02-02 17:26:10

 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     exceptions handling  cloning




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

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:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: