Week 16: Java Class Constructor Flashcards
It is a special method that is used
to initialize objects.
A constructor
It is called when an object of a class is created.
The constructor
It can be used to set initial values for object attributes.
The constructor
Constructors are almost similar to methods except for two things
- Its name is the same as the class name.
- It has no return type.
Sometimes constructors are also referred to as ________ to initialize an object.
special methods
It is used to create the instance of
the class.
The constructor
Another way to assign values to public field variables
A constructor
When the object is created, Java calls the ______ first. Any code you have in your constructor will then get executed.
constructor
Constructor methods take the same name as the ____.
class
______ don’t need a return type like int or double, nor any return value.
Class constructors