1/55
Vocabulary flashcards covering identifiers, literals, types, variables, operators, subroutines, objects, arrays, and basic Java concepts from the video notes.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Identifier
A valid Java name that can refer to classes, variables, or subroutines; must start with a letter or underscore and contain only letters, digits, and underscores; is case sensitive and cannot be a reserved word.
Reserved words
Java keywords like class, public, static, if, else, while; they cannot be used as identifiers.
camelCase
Naming convention where multi-word identifiers start with a lowercase letter and each subsequent word begins with an uppercase letter.
camelCase vs underscores
Camel case is preferred for class names (UpperCamelCase) and variables/methods for lowerCamelCase; underscores are less common in Java identifiers.
Compound name
A name that contains multiple simple names separated by periods, e.g., System.out.println, indicating containment and hierarchy.
Variable
A memory reference (a box) used to store data; a variable refers to the box and indirectly to the data inside it.
Assignment statement
A command of the form variable = expression that stores the value of the expression into the variable; executes at a specific time during program run.
Primitive types
Eight built-in types in Java: byte, short, int, long, float, double, char, and boolean.
byte
8-bit integer type with range -128 to 127; stores a single byte of memory.
short
16-bit integer type; range -32768 to 32767.
int
32-bit integer type; commonly used for integers in Java.
long
64-bit integer type; large range for integers.
float
32-bit floating-point type; used for real numbers with about 7 digits of precision.
double
64-bit floating-point type; more precision than float; standard for real numbers.
char
16-bit Unicode character type; holds a single character.
boolean
Logical true/false type.
Literal
A fixed constant value written directly in code, such as 317, 3.14, true, 'A', or "Hello".
Char literal
A single character enclosed in single quotes, e.g., 'A' or '\t'.
String literal
A sequence of characters enclosed in double quotes, e.g., "Hello World"; distinct from a char literal.
Escape sequences
Special character sequences like \t, \r, \n, \' and \ used inside character or string literals.
Unicode escape
A character literal like '\u00E9' representing a Unicode code point.
Numeric literals
Decimal numbers; may include exponential form (e notation); real numbers with a decimal point or exponent are doubles by default.
Underscores in numeric literals
You can use underscores in numeric literals for readability, e.g., 2000000_000.
Binary/Octal/Hex literals
Numeric literals can be binary (0b…), octal (leading 0), or hexadecimal (0x…); the bases use 0-9 and A-F (case-insensitive).
Boolean literals
Two constants of type boolean: true and false.
String
A non-primitive object type representing a sequence of characters; String literals use double quotes.
String vs char
Char is a single character; String is a sequence of characters; they are different types.
Literals vs variables
Literals are fixed values in code; variables store values that can change during execution.
Arithmetic operators
+, -, *, / are the basic arithmetic operators; can be applied to numeric types and char treated as integers.
Type conversion
Automatic or explicit conversion between numeric types; e.g., int to double; mixing int and double may promote to double.
Integer division caveat
Dividing two integers yields an integer result (fraction discarded). To get a real result, cast to double or use a double literal.
Modulo operator
The % operator returns the remainder of division; behavior with negative values is implementation-defined for Java.
Increment/Decrement
++ and -- operators; post-increment (x++) returns old value, pre-increment (++x) returns new value; similarly for decrement.
String concatenation with +
Using + with a String and another type results in a String; automatic conversion to String occurs.
Relational operators
Compare values: ==, !=,
Double.NaN
A special double value representing Not-a-Number; comparisons with NaN behave unexpectedly; use Double.isNaN(x) to test.
Boolean operators
Logical AND (&&), OR (||), and NOT (!) with short-circuit evaluation.
Conditional operator
The ternary operator expression: condition ? expr1 : expr2; returns one of two expressions based on the boolean condition.
Assignment operators
Compound assignments like +=, -=, *=, /=, %= are shorthand for applying an operation then assigning the result.
Precedence rules
Operator precedence determines evaluation order; multiplication/division bind tighter than addition/subtraction; parentheses can override.
Subroutine (method)
A block of code inside a class used to perform a task; can be static or instance (non-static); may return a value.
Return statement
Used in a function to exit and produce a value; a void method uses return; non-void methods must return a value.
Formal vs actual parameters
Formal parameters are the names in a method definition; actual parameters are the values supplied in a method call.
Overloading
Having multiple methods with the same name but different parameter signatures within a class.
Static vs non-static
Static members belong to the class; non-static (instance) members belong to objects; static data is shared.
Main method
The program entry point: public static void main(String[] args).
Constructor
A special method with no return type and same name as the class; used to create and initialize objects; can be overloaded.
new operator
Creates a new object and returns a reference to it; calls the constructor.
Null
A special value for reference variables indicating no object is referenced; dereferencing causes NullPointerException.
Garbage collection
Java's automatic memory management that reclaims objects that are no longer reachable.
Object vs class
A class is a blueprint; an object is an instance created from a class; objects have their own data (instance variables) and behavior (methods).
Instance vs static members
Instance members belong to objects; static members belong to the class and are shared across all instances.
Equals vs '==' for objects
'==' checks reference equality; .equals() checks value/content equality for objects like Strings.
Arrays
A fixed-length, ordered collection of elements of the same base type; arrays are objects; elements are accessed by index starting at 0.
For-each loop
Enhanced for loop: for (Type item : array) { … } to iterate over elements without using indices.
Exception handling
Try-catch blocks to handle runtime errors; exceptions can be NumberFormatException, IllegalArgumentException, etc.