Week 16: Java Class Constructor Flashcards

1
Q

It is a special method that is used
to initialize objects.

A

A constructor

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

It is called when an object of a class is created.

A

The constructor

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

It can be used to set initial values for object attributes.

A

The constructor

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

Constructors are almost similar to methods except for two things

A
  1. Its name is the same as the class name.
  2. It has no return type.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Sometimes constructors are also referred to as ________ to initialize an object.

A

special methods

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

It is used to create the instance of
the class.

A

The constructor

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

Another way to assign values to public field variables

A

A constructor

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

When the object is created, Java calls the ______ first. Any code you have in your constructor will then get executed.

A

constructor

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

Constructor methods take the same name as the ____.

A

class

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

______ don’t need a return type like int or double, nor any return value.

A

Class constructors

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