Constructors Flashcards
How many arguments does the default constructor take?
None.
What is the access type of a default constructor?
It is the same as the access type of the class.
I.e., if the class is public, so is the default constructor.
T/F: A constructor is non-static
True.
It can access both static and non-static members of the class.
Does a constructor need to initialize all member variables of a class?
No.
Non-final members will be assigned a default value.
Can a constructor declare a return value?
No.
Can a constructor be declared private?
Yes.
This is used for implementing singleton classes.
Do all Java classes get a default constructor?
No.
If a class explicitly defines a constructor it will not get the default constructor.
What does the default constructor call?
The no-args constructor of the super class.
What must an abstract class declaration have to be valid?
It must have the abstract keyword and may not have a method body.
What does the final keyword mean when applied to a class? a method? a variable?
Applied to a class, it means no further sub-classing.
To a method it means no method overridding.
To a variable it makes it a constant.