1/24
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Constructor
A special block of code in a class that runs automatically when a new object is created (with new) to initialize the object’s instance variables to a valid starting state.
Instance variable (field)
A variable declared in a class (outside methods/constructors) that stores an object’s ongoing state; each object has its own copy.
new operator
Java keyword used to create an object; it allocates memory, invokes a matching constructor, and returns a reference to the new object.
Constructor naming rule
A constructor’s name must exactly match the class name.
Constructor return type rule
A constructor has no return type at all (not even void); adding a return type turns it into a regular method.
Object reference variable
A variable that stores a reference (address) to an object in memory (e.g., Student s refers to a Student object).
Shadowing
A naming conflict where a parameter or local variable has the same name as an instance variable, causing the parameter/local name to hide the field name inside the method/constructor.
this keyword
A reference to the current object; used to access instance variables/methods explicitly (e.g., this.name) and to resolve shadowing.
Common constructor shadowing bug
Writing name = name; when a parameter shadows a field, which assigns the parameter to itself and leaves the instance variable unchanged (default value remains).
Default initialization
If you don’t explicitly assign a field, Java gives it a default value (e.g., numeric primitives → 0, boolean → false, references like String → null).
No-argument constructor (no-arg constructor)
A constructor with no parameters (e.g., public Student() { ... }) used to create objects with default/placeholder starting values.
Automatic default constructor rule
If a class defines no constructors, Java provides an automatic no-arg constructor; if you define any constructor, Java does not add a no-arg constructor for you.
Constructor overloading
Having multiple constructors with the same name (class name) but different parameter lists so objects can be initialized in different valid ways.
Parameter list matching (constructor selection)
When you call new ClassName(...), Java chooses the overloaded constructor whose parameter types/number best match the arguments provided.
Constructor chaining with this(...)
Calling another constructor in the same class from within a constructor (e.g., this(name, 9);) to reuse initialization logic and avoid repetition.
this(...) first-statement rule
If a constructor calls this(...), it must be the first statement in that constructor.
Method
A named block of code in a class that defines behavior (actions/computations) and is executed only when called.
Method signature
The method’s identifying header information used for overloading: method name plus parameter types (not the return type).
Access modifier
A keyword like public that controls where a constructor/method can be accessed (e.g., public means callable from outside the class).
Local variable
A variable declared inside a method/constructor (including parameters) that exists only while that method/constructor runs.
Dot notation (method call syntax)
Calling an instance method on an object using object.methodName(...); the object is the “receiver” of the call.
void method
A method that performs an action but returns no value; it must be called as a standalone statement, not used where a value is required.
Return statement
A statement that immediately ends a method; in non-void methods it also provides a value back to the caller, and all possible paths must return a value.
Accessor method (getter)
A method (often public, non-void, usually no parameters) that returns information about an object’s state without changing it (supports encapsulation).
Encapsulation
An OOP practice of keeping fields private and providing controlled access through methods (e.g., getters) to protect data and maintain valid object state.