Constructors Flashcards

1
Q

What they do

A

Make it simpler for initialising a lot of objects

Special method to initialise class variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Constructor set up

A

Have capitol of method and don’t have a return type

(){
Body
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

   } }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Multiple constructors

A

Used to initialise different members.

Class can have multiple constructors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Parameters of a constructor are?

A

LOCAL PARAMETERS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly