1/31
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Class
A blueprint or template that defines the state (variables) and behaviour (methods) that all objects of that type will have. No memory is allocated for a class itself — only for objects created from it.
Object
A specific instance of a class, created using the new keyword. Each object has its own copy of the instance variables but shares the same method definitions.
Instantiation
The process of creating an object from a class using the new keyword. This allocates memory for the object and calls the constructor.
Constructor
A special method that runs automatically when an object is created with new. It has the same name as the class and no return type. Used to initialise instance variables. Can be overloaded.
Instance Variable
A variable declared at class level (not inside a method). Each object gets its own independent copy. Almost always declared private.
Encapsulation
Bundling an object's data (attributes) and the methods that operate on that data into a single unit (the class), while hiding the internal details from outside code. Achieved using private fields and public getter/setter methods.
Accessor Method
A public method that returns the value of a private instance variable. Named getFieldName(). Takes no parameters and has a return type matching the field.
Mutator Method
A public method that sets the value of a private instance variable. Named setFieldName(). Takes one parameter and returns void. Can include validation logic.
“this” Keyword
A keyword that refers to the current object. Used inside a method or constructor to distinguish between an instance variable and a parameter with the same name.
Inheritance
A mechanism where a subclass (child) acquires all the attributes and methods of a superclass (parent). Declared with extends. Represents an 'is a' relationship. Java only allows single inheritance.
Superclass
The parent class in an inheritance relationship. Its attributes and methods are inherited by all subclasses. Also called base class or parent class.
Subclass
The child class in an inheritance relationship. It inherits all attributes and methods of its superclass and can add new ones or override existing ones. Declared with extends.
“extends” Keyword
The Java keyword used to declare that a class inherits from another class.
“super” Keyword
A keyword that refers to the superclass. Used in two ways: super() calls the superclass constructor (must be first line); super.method() calls the superclass version of an overridden method.
“@Override” Annotation
An annotation placed before a method to indicate it replaces a superclass method. The compiler checks the signatures match exactly. Not required but strongly recommended.
Polymorphism
The ability for objects of different classes to be treated as objects of a common superclass type. The method called depends on the actual type of the object at runtime, not the reference type. Two forms: overriding (runtime) and overloading (compile-time).
Overriding
When a subclass provides its own implementation of a method that already exists in the superclass. The method name, parameters, and return type must match exactly. Uses @Override annotation.
Overloading
When a class has multiple methods with the same name but different parameter lists (different number or types of parameters). The compiler picks the right one at compile-time.
“instanceof” Operator
An operator that tests whether an object is an instance of a specified class or its subclasses. Returns a boolean. Returns false if the object is null — never throws an exception.
Type Casting
Converting a superclass reference to a subclass type to access subclass-specific methods. Must be done explicitly with (SubclassName). Throws ClassCastException if the object is not actually that type.
Access Modifier
A keyword that controls the visibility of a class, field, or method. The three main ones in Java are public (+), private (-), and protected (#). Used in UML notation too.
“static” Keyword
A keyword indicating that a variable or method belongs to the class itself, not to any individual object. All objects share one copy of a static variable. Static methods cannot access instance variables.
“final” Keyword
A keyword that makes a variable constant — it can only be assigned once and cannot be changed. Convention: name constants in ALL_CAPS. Used to avoid 'magic numbers' in code.
“toString()” Method
A method inherited from the Object class. By default it returns a memory address string. Override it in your classes to return a meaningful text representation of the object.
“equals()” Method
A method inherited from the Object class. By default it compares memory addresses (same as ==). Override it to compare objects by their field values instead. Parameter MUST be Object.
UML Class Diagram
Unified Modelling Language visual notation for representing classes, their attributes, methods, and relationships. Each class is a box with three sections: name, attributes, methods. Visibility shown with +, -, # symbols.
Aggregation
A UML 'has a' relationship where the child can exist independently of the parent. Shown with a hollow diamond on the parent side. Weak ownership — the child's lifecycle is not controlled by the parent.
Composition
A UML 'part of' relationship where the child cannot exist without the parent. Shown with a filled diamond on the parent side. Strong ownership — child is created and destroyed with the parent.
Multiplicity
UML notation showing how many objects participate in a relationship. Written at each end of a relationship line.
Modularity
Designing a program as independent, interchangeable units (modules/classes) that can be developed, tested, and maintained separately. Each module has a clear, single responsibility.
Association
Association is a UML relationship representing a general "has a" or "uses a" connection between two classes, where both can exist independently of each other. It's the most basic relationship type — just a solid line between the two classes.
Dependency
A relationship where one class uses another class, typically temporarily — for example as a method parameter, a local variable, or a return type. It is shown in UML as a dashed arrow pointing from the class that depends on the other to the class being used.