|
Section 1 :Declaration and Access
Control
For a given class, determine if
a default constructor will be created, and if so,
state the prototype of that constructor.
If
there are no constructors defined in a class, Java
provides a default constructor. This constructor is a
no-args constructor and it simply sets all the fields
of the object to their default values. So, all numeric
data contained in the fields would be zeroed out, all
boolean values would be
set to false, and all reference variables set to null.
If there is even a single constructor defined in a
class, Java will not create the default constructor.
The signature of this default constructor is like
this:
public ClassName () { }
where ClassName is the name of the class for which
this constructor has been provided.
section1-1 | section1-2 | section1-3 | section1-4
Sections :
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11
|