Constructor Overloading In Java Example
Example 1: default constructor java
Default constructor is a constructor created by compiler; if user does not
create a constructor in a class.
If user defines a constructor in a class then java compiler will not create
default constructor.
Example 2: Can we overload the constructors
Yes, the constructors can be overloaded by changing the number of
arguments accepted by the constructor or by changing the data type of
the parameters
Comments
Post a Comment