1/184
(Created with AI)
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Compiler
Translates Java source code (.java) into bytecode (.class) that the JVM can run
JVM (Java Virtual Machine)
Runs compiled Java bytecode, which makes Java platform independent
JDK vs JRE
JDK contains the tools to develop Java (compiler, debugger); JRE only contains what is needed to run Java programs
Bytecode
Platform independent intermediate code produced by the Java compiler
Syntax error
Code that breaks the language rules; caught at compile time
Runtime error
Error that occurs while the program runs (e.g. exception, division by zero)
Logic error
Program runs but produces wrong results because the algorithm is wrong
Primitive type
Basic built in type stored directly as a value: byte, short, int, long, float, double, char, boolean
Reference type
Variable that stores the address of an object on the heap (classes, arrays, String)
Variable
Named memory location with a type that holds a value
Declaration vs initialization
Declaration states type and name (int x;); initialization gives the first value (x = 5;)
Literal
A fixed value written directly in code (e.g. 42, 3.14, 'a', "hello", true)
Constant (final)
Variable declared with final; its value cannot change after assignment
Casting
Converting a value from one type to another; widening is implicit, narrowing needs an explicit cast
Integer division
Division of two ints discards the fractional part (7 / 2 == 3)
Modulo operator (%)
Gives the remainder after division (7 % 2 == 1)
Operator precedence
The order in which operators are evaluated in an expression
Short circuit evaluation
&& and || stop evaluating as soon as the result is known
Increment/decrement (++ / --)
Adds or subtracts 1; prefix changes the value before use, postfix after use
Overflow
A value exceeds the range of its type and wraps around
Expression
Code that evaluates to a single value
Statement
A complete instruction ending in a semicolon
Scope
The region of code where a variable is visible and usable
Block
Code between curly braces { } that defines a scope
Conditional
Control flow that executes code depending on a boolean condition (if, else if, else, switch)
Switch statement
Selects one of many code paths based on the value of an expression
Ternary operator
Shorthand conditional: condition ? valueIfTrue : valueIfFalse
Loop
Repeats code while a condition holds (for, while, do while, enhanced for)
Enhanced for loop (for each)
Iterates over every element of an array or Iterable without using an index
do while loop
Loop that checks its condition after the body, so it runs at least once
break
Immediately exits the nearest enclosing loop or switch
continue
Skips the rest of the current loop iteration and moves to the next one
Infinite loop
Loop whose condition never becomes false
Off by one error
Bug where a loop or index runs one time too many or too few
Method
Named block of code that performs a task, can take parameters and return a value
Parameter vs argument
Parameter is the variable in the method definition; argument is the actual value passed in the call
Return type
The type of value a method gives back; void means nothing is returned
Method signature
Method name plus its parameter types (return type not included)
Method overloading
Several methods with the same name but different parameter lists in the same class
Pass by value
Java copies the argument; for objects the copy of the reference is passed
Recursion
A method that calls itself, needs a base case to stop
Base case
The condition in a recursive method that stops further recursive calls
Call stack
Structure of stack frames for active method calls
Class
Blueprint that defines the fields and methods of objects
Object
An instance of a class with its own state stored in its fields
Instance
A specific object created from a class
Field (attribute)
Variable that belongs to an object (instance variable) or class (static variable)
Instance variable
Field with a separate copy for each object
Local variable
Variable declared inside a method; exists only during that call and has no default value
Constructor
Special method with the class name and no return type that initializes a new object
Default constructor
Constructor with no parameters that Java provides only if you write no constructors yourself
this
Reference to the current object; also used to call another constructor (this(…))
new
Keyword that allocates memory for a new object and calls its constructor
null
Special value meaning a reference points to no object
NullPointerException
Thrown when you use a reference that is null
Encapsulation
Hiding internal state (private fields) and exposing it only through methods
Getter / setter
Methods that read or modify a private field in a controlled way
Access modifier
Controls visibility: public, protected, package private (default), private
private
Visible only inside the declaring class
protected
Visible in the same package and in subclasses
public
Visible everywhere
Package
Namespace that groups related classes
Import
Statement that makes classes from another package usable by their short name
static
Belongs to the class itself rather than to any specific object
Static method
Method that can be called without an object and cannot use this or instance fields directly
Static vs dynamic binding
Static binding is decided at compile time (overloading, static, private); dynamic binding is decided at runtime based on the actual object (overriding)
Garbage collection
Automatic removal of objects that are no longer referenced
Stack
Memory for method calls, local variables and references
Heap
Memory where all objects live
Aliasing
Two or more references pointing to the same object
Immutable object
Object whose state cannot change after creation (e.g. String)
Wrapper class
Object version of a primitive (Integer, Double, Boolean, Character)
Autoboxing / unboxing
Automatic conversion between a primitive and its wrapper class
toString()
Method that returns a String representation of an object; called implicitly when printing
equals()
Method that checks logical equality of objects; default implementation compares references
hashCode()
Returns an int hash for an object; equal objects must have equal hash codes
equals/hashCode contract
If a.equals(b) then a.hashCode() == b.hashCode(); override both together
== vs equals
== compares primitive values or references; equals compares object content (if overridden)
compareTo()
Method of Comparable that defines natural ordering (negative, zero, positive)
Comparable
Interface with compareTo that gives a class a natural ordering
Comparator
Interface that defines a custom ordering through compare(a, b)
Array
Fixed size, indexed collection of elements of the same type
Array index
Position of an element in an array, starting at 0
ArrayIndexOutOfBoundsException
Thrown when an array index is negative or at least the array length
Multidimensional array
Array of arrays, e.g. int[][]
Collection
Object that groups multiple elements (List, Set, Queue)
ArrayList
Resizable array backed List that keeps insertion order and allows duplicates
LinkedList
List implemented as a chain of nodes; fast insertion and removal at the ends
List
Ordered collection that allows duplicates and access by index
Set
Collection with no duplicate elements
HashSet
Set based on hashing; no guaranteed order, fast lookup
TreeSet
Set that keeps its elements sorted
Map
Collection of key value pairs with unique keys
HashMap
Map based on hashing; no guaranteed order, fast lookup by key
Iterator
Object used to traverse a collection element by element (hasNext, next, remove)
Generics
Allow classes and methods to work with a type parameter (e.g. List
Diamond operator <>
Lets the compiler infer the generic type arguments (new ArrayList<>())
Inheritance
A subclass acquires the fields and methods of a superclass (extends)
Superclass / subclass
Parent class that is extended / child class that extends it
is a relationship
Inheritance models "is a" (a Dog is an Animal)