Saturday 16 February 2019

What is copy constructor in Java? tccicomputercoaching.com

Constructor in java is a special type of method that is used to initialise the object.

Two types of constructors in Java

1. Default constructor( No need to pass parameters)

2. parameterized constructor



Copy constructor is a parameterized constructor and Copy Constructor is used to create an exact copy of an object with the same values of an existing object.

If you want to make a copy of an object while instantiating, then a copy constructor is used to achieve this. If you pass objects as function argument, it is passed as value, but since it’s a copy of reference it’s actually pointing to the same memory and thus it becomes call by reference.

To learn more about Constructor, Other topics of Java and Programming Languages

Call us @ 9825618292

Visit us @ http://tccicomputercoaching.com/course/

No comments:

Post a Comment