Constructors Flashcards
1
Q
What they do
A
Make it simpler for initialising a lot of objects
Special method to initialise class variables
2
Q
Constructor set up
A
Have capitol of method and don’t have a return type
(){
Body
}
3
Q
Parameterless constructor
A
Constructor with no arguments. Java creates parameterless constructor (no arguments)
I.e class Customer {
}
Note: Java sets initial default values to null or 0
4
Q
Parameterised constructor
A
Accepted parameters which are assigned to instance variables of the class for that object
Class Customer {
Instant variables Customer(dat type variables) { Assign parameters to instant variable } }
5
Q
Multiple constructors
A
Used to initialise different members.
Class can have multiple constructors
6
Q
Parameters of a constructor are?
A
LOCAL PARAMETERS