What is a Constructor, Constructor Overloading in Java and Copy-Constructor ?
What is a Constructor, Constructor Overloading in Java and Copy-Constructor ?
Answer
A constructor gets invoked when a new object is created. Every class has a constructor In case the programmer does not provide a constructor for a class, the Java compiler (Javac) creates a default constructor for that class.
The constructor overloading is similar to method overloading in Java. Different constructors can be created for a single class. Each constructor must have its own unique parameter list.
Finally, Java does support copy constructors like C++, but the difference lies in the fact that Java doesn’t create a default copy constructor if you don’t write your own.
Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website.
If you are using this website then its your own responsibility to understand the content of the website