Q: What is object cloning in Java?
-
A
Object cloning is the process of creating an exact copy of an object.
-
B
Object cloning is the process of creating a new object using a copy constructor.
-
C
Object cloning is the process of creating a new object with the same reference as the original object.
-
D
Object cloning is not supported in Java.
A
Answer:
A
Explanation:
Object cloning in Java is the process of creating an exact copy of an object. This process is done by using the clone() method of the Object class. The clone() method creates a new object with the same state as the original object. The new object is an exact copy of the original object, including all its fields and methods. The clone() method also ensures that the new object is of the same type as the original object.
Related Topic:
Share Above MCQ