Flashcards · Java · Free
Java flashcards, generated for you.
Example Java study cards to learn from right now — then generate a full set from your own notes (plus a practice quiz) and export to Quizlet or Anki. Free, no account needed.
Example Java flashcards
What is the difference between `==` and `.equals()` when comparing strings in Java?
`==` compares object references (memory addresses); `.equals()` compares the actual string content. Use `.equals()` for string content comparison.
What does `null` represent in Java?
`null` is a special literal value representing the absence of an object reference. Variables can be assigned `null`, but calling methods on `null` throws `NullPointerException`.
What is the difference between primitive types and reference types?
Primitives (int, boolean, double, etc.) store values directly on the stack; references (objects, arrays, strings) store memory addresses pointing to heap data.
Why does `int x = 5; Integer y = x;` work without explicit casting?
Autoboxing automatically converts primitives to their wrapper classes (Integer, Boolean, etc.) and vice versa (unboxing). This is syntactic sugar introduced in Java 5.
What happens when you concatenate a string with `null`? Example: `"Value: " + null`
The `null` is converted to the string "null", resulting in "Value: null". No exception is thrown.
Explain the difference between `final`, `finally`, and `finalize()` in Java.
`final` prevents modification (variables, methods, classes); `finally` is a block that executes after try/catch; `finalize()` is a deprecated method called by garbage collector before object destruction.
What is the difference between checked and unchecked exceptions?
Checked exceptions must be declared in the method signature or caught (IOException, SQLException); unchecked exceptions (RuntimeException subclasses) do not require declaration or catching (NullPointerException, ArrayIndexOutOfBoundsException).
Why does this code print '0' instead of '10'? `int x = 5; int y = x++ + ++x;`
Post-increment (`x++`) returns the old value; pre-increment (`++x`) returns the new value. The evaluation order and side effects make this undefined behavior in Java—avoid relying on it. The actual result depends on JVM optimization.
What is the difference between `ArrayList` and `Array` in Java?
`ArrayList` is a resizable, dynamic collection (reference type) in java.util; arrays have fixed size. `ArrayList` uses `.add()` and `.get()`; arrays use index notation. `ArrayList` is slower but more flexible.
In Java, does passing an object to a method pass it by value or by reference?
Java passes objects by value—the reference itself is copied, not the object. Changes to the object's fields affect the original; reassigning the reference parameter does not affect the original variable.
Make your own Java study set
Flashcards for related topics
Studying Java to build with AI? MindloomHQ turns it into real skills — structured courses, agent projects, and certificates.
Explore MindloomHQ →