What is copy constructor in Java? tccicomputercoaching.com

Page 1

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. 2.

Default constructor( No need to pass parameters) 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/


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.