Google Interview Question
Software Engineer / DevelopersFrom wikipedia,
The following cases may result in a call to a copy constructor:
1. When an object is returned by value
2. When an object is passed (to a function) by value as an argument
3. When an object is thrown
4. When an object is caught
5. When an object is placed in a brace-enclosed initializer list
to create copies of the object
- vvg September 26, 2010class person{
String name;
int age;
public person(){
}
public person(person p)
name=p.name;
age=p.age;
}
person(person) is copy consructor