1.

Define Copy constructor in java.

Answer»

Copy CONSTRUCTOR is the constructor USED when we want to initialize the value to the NEW object from the OLD object of the same class. 

class InterviewBit{ String department; String service; InterviewBit(InterviewBit ib){ this.departments = ib.departments; this.services = ib.services; }}

Here we are initializing the new object value from the old object value in the constructor. ALTHOUGH, this can also be achieved with the help of object cloning.



Discussion

No Comment Found