Knowee
Questions
Features
Study Tools

Select the correct answerWhich of these method of Object class can clone an object?Optionscopy()Objectcopy()Object clone()clone()

Question

Select the correct answerWhich of these method of Object class can clone an object?Optionscopy()Objectcopy()Object clone()clone()

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct answer is "Object clone()". This is the method of the Object class that can clone an object in Java.

Similar Questions

t answerWhich of these method of Object class can clone an object?

Assume class DEMO. Which of the following statement(s) responsible to invoke copy constructor?1. DEMO D2(D1); // Here D1 is an already created object of class DEMO2. D2 = D1; // Here D1, D2 are already created objects of class DEMOThis problem has only one correct answerOnly 1Only 2Both 1 and 2

public class Person{             int age;             String name;             public Person(String n, int a){                 age = a;                 name = n;             }             public String toString(){                 return (name+ ":" + age );             }         }         public class Employee extends Person implements Cloneable {             public Employee(String n, int a){                 super(n, a);             }             public Employee clone()throws CloneNotSupportedException{                 return (Employee)super.clone();              }         }         public class Test {             public static void main(String[] args) {                 Employee[] e1 = {new Employee("Hari",30), new Employee("geeta",23)};                 Employee[] e2 = e1.clone();                 e2[1].name = "rani";                 System.out.println(e1[1] + ", " + e2[1]);              }          }

Which of the following methods is used to copy elements from one ArrayList to another?Question 2Answera.Collections.copy()b.duplicate()c.clone()d.copy()

When a copy constructor may be called?Option 1When an object is constructed based on another object of the same classOption 2When an object of the class is passed (to a function) by value as an argument.Option 3When compiler generates a temporary object.Option 4All of these

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.