1/49
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Object
A bundle of data (state) and behavior (methods) that you interact with in Java.
State
The data an object “remembers” (e.g., the characters stored in a String, or a Scanner’s current reading position).
Method
A function that belongs to a class/object and can be called to perform an action or compute a value (e.g., length(), nextInt()).
Class
A definition/blueprint that specifies what state and methods its objects have; used as the type for object variables.
Object-oriented programming (OOP)
A programming approach where most work is done by creating objects and calling methods on them.
Java API (Application Programming Interface)
The collection of prewritten Java library classes and methods you are expected to use (e.g., String, Math, wrapper classes).
Instance method
A method called on an object reference (e.g., str.length()); typically uses that object’s state.
Static method
A method called on a class name rather than an object (e.g., Math.sqrt(9)); no instance is needed.
Method signature
A method’s name plus its parameter types (often considered along with its return type); used to determine which method call is valid.
Reference type
A type that refers to an object (class types like String); variables store references, not the object’s contents directly.
Reference variable
A variable of a class type that holds a reference (address/handle) to an object in memory, or null.
Aliasing
When two reference variables refer to the same object (e.g., b = a; copies the reference, not the object).
null
A literal meaning “no object”; can be assigned to any reference variable.
NullPointerException
A runtime error that occurs when you try to use null like an object (e.g., calling a method on a null reference).
Empty string ("")
A real String object with length 0; it is not the same as null.
new keyword
Allocates a new object in memory and returns a reference to it (e.g., new Scanner(System.in)).
Constructor
Special code that runs when an object is created; has the same name as the class, has no return type, and may take parameters (can be overloaded).
Scanner
A Java library class used to read input; commonly constructed as new Scanner(System.in) and then used via instance methods.
Dot operator (.)
Used to call an instance method/field on an object reference: objectRef.methodName(args).
Parameter
A variable in a method/constructor definition that receives a value when the method/constructor is called.
Argument
The actual value passed into a method/constructor call (e.g., in s.substring(2,5), 2 and 5 are arguments).
Void method
A method that performs an action but returns no value (cannot be stored/used as an expression), e.g., println(…).
Non-void method
A method that returns a value; the call evaluates to that value and can be stored or used in expressions (e.g., s.length()).
Return type
The type of value a non-void method produces (e.g., length() returns int; substring(…) returns String).
Method chaining
Calling a method on the object returned by a previous method call (e.g., "hello".toUpperCase().substring(1)).
String
A Java class representing text; String values are objects with many commonly tested methods (length, substring, indexOf, equals, compareTo).
String immutability
Strings cannot be changed after creation; most String methods return a new String rather than modifying the original.
0-based indexing
String character positions start at 0; the last valid index is length() - 1.
StringIndexOutOfBoundsException
A runtime error caused by using an invalid String index (e.g., negative or ≥ length()).
String.length()
Returns the number of characters in a String as an int (spaces count as characters).
String.substring(int beginIndex)
Returns a new String from beginIndex to the end of the original String.
String.substring(int beginIndex, int endIndex)
Returns a new String from beginIndex up to (but not including) endIndex.
Exclusive endIndex (substring rule)
In substring(beginIndex, endIndex), the character at endIndex is not included; endIndex is one past the last included index.
String.indexOf(…)
Searches for a character/substring and returns the index of the first occurrence; returns -1 if not found.
String.equals(…)
Compares String contents (characters) for equality; use this instead of == for text comparison.
== operator (reference comparison)
For objects, checks whether two references point to the same object (not whether contents match); unreliable for String content comparison.
String.compareTo(…)
Lexicographically compares two strings and returns an int: negative if calling string comes before, 0 if equal, positive if after.
Wrapper class
An object type that wraps a primitive value (e.g., Integer for int, Double for double, Boolean for boolean).
Autoboxing
Automatic conversion from a primitive to its wrapper (e.g., Integer a = 7;).
Unboxing
Automatic conversion from a wrapper object to its primitive (e.g., int b = a;).
Integer.parseInt(String)
Converts a numeric String into an int; throws NumberFormatException if the String is not a valid integer.
Double.parseDouble(String)
Converts a numeric String into a double; throws NumberFormatException if the String is not a valid number.
NumberFormatException
A runtime error thrown when parsing a String into a number fails due to invalid format.
Unboxing null pitfall
If a wrapper reference is null and Java tries to unbox it to a primitive, a NullPointerException occurs (e.g., Integer n=null; int x=n;).
Math class
A utility class of static math methods (no Math objects are created); methods are called like Math.methodName(…).
Math.sqrt(x)
Static method that returns the square root of x as a double (even if x is an int).
Math.pow(a, b)
Static method that returns a raised to the power b as a double.
Math.random()
Returns a double in the range [0.0, 1.0), meaning 0.0 is possible but 1.0 is not.
Casting to int (truncation)
(int) applied to a double drops the decimal part (truncates toward 0); it does not round.
Random integer patterns with Math.random()
Common patterns: 0..n-1: (int)(Math.random()n). a..b inclusive: (int)(Math.random()(b-a+1))+a. Pitfall: (int)Math.random()*n casts too early and usually becomes 0.