Sunday, June 15, 2014

What is Constructors, Constructor Overloading in Java and Copy-Constructor?

java has defualt no arument constructors

WRONG if you make one with parameters you also need to write a no arg default const (no you dont - tested) thanks random internet blog for incorrect info..!!



can be public, private or protected

called once to instantiate

same name as class

no return value and dont need void

dont have to write one as java creates a default one

just use   new Classname();


Copy Constructor: A copy constructor is a type of constructor which constructs the object of the class from another object of the same class. The copy constructor accepts a reference to its own class as a parameter.


No comments:

Post a Comment