VISUAL BASIC

INTRODUCTION TO NET

APPLICATION DEVELOPMENT

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
When a developer wants to create an exact copy of an object, s/he has to create a new object of the same class.
A
True
B
False
C
Either A or B
D
None of the above
Explanation: 

Detailed explanation-1: -The object cloning is a way to create exact copy of an object. The clone() method of Object class is used to clone an object.

Detailed explanation-2: -To create a copy of an existing object in the vault, right-click the object of your choice and select Make Copy from the context menu. This command creates an entirely new object using the metadata and contents of the source object.

Detailed explanation-3: -The clone() method of the class java. lang. Object accepts an object as a parameter, creates and returns a copy of it.

Detailed explanation-4: -A copy constructor is a member function that initializes an object using another object of the same class.

Detailed explanation-5: -The clone keyword is used to create a copy of an object.

Detailed explanation-6: -Clone() Method This method belongs to the Object class, which is a base class of every class created in Java. This method helps to create a copy of the object, but if the class doesn’t support a cloneable interface then it leads to the exception, “ CloneNotSupportedException".

There is 1 question to complete.