What does `==` compare for two Java object references?
Answer & explanation
Answer: Whether both references point to the same object
For objects, `==` compares reference identity. Use an appropriate `equals` implementation for value equality.
Work through Java types, collections, exceptions, strings, and object behavior.
A random set of up to 10 questions from Java. Your answers stay on this page.
Open a topic above to explore the complete question bank.
Answer: Whether both references point to the same object
For objects, `==` compares reference identity. Use an appropriate `equals` implementation for value equality.
Answer: Set
A `Set` models unique elements. A `List` permits duplicates and preserves positional order.
Answer: finally
`finally` normally runs after `try`/`catch`, making it useful for cleanup.
Answer: map
`map` transforms elements; `filter` keeps matching elements; `forEach` performs an action.
Answer: Mutual exclusion and memory visibility
A synchronized region is mutually exclusive for a monitor and establishes visibility guarantees.
public ___ size() {
return 3;
}Answer: int
The declared return type must match the returned value; `3` is an `int`.