Compare sorted containers, anonymous classes, factory methods, serialization fields, thread lifecycle, and modern constructor rules.
Answer: SortedSet stores unique elements in comparison order; SortedMap stores key/value associations ordered by keys. They are interfaces in java.util, not nested types of the Collections utility class. In Java SE 25 they extend SequencedSet and SequencedMap respectively.
NavigableSet and NavigableMap add nearest-value and range navigation. Map does not extend Collection, and sorted membership uses comparison equality, which should agree with equals.
Answer: It is an unnamed class declared as part of an instance-creation expression, such as an implementation of an interface or subclass of a class. It can define members and override methods but cannot declare a named constructor. Captured local variables must be final or effectively final.
A lambda is often shorter for a functional interface but has different this semantics. An anonymous class in a static context does not require an enclosing instance.
Answer: A creator defines an operation that obtains a product through an overridable creation method. Subclasses choose the concrete product, allowing the creator's workflow to depend on the product abstraction. This is distinct from simply calling any static helper a factory.
public class FactoryWorkflow {
interface Report { String render(); }
static abstract class Exporter {
protected abstract Report createReport();
final String export() { return createReport().render(); }
}
static final class TextExporter extends Exporter {
@Override protected Report createReport() {
return () -> "Text report";
}
}
public static void main(String[] args) {
Exporter exporter = new TextExporter();
System.out.println(exporter.export());
}
}
Here export owns the workflow and createReport is the Factory Method. Constructor injection or a supplied factory function can be simpler when subclass variation is unnecessary.
Answer: Object defines the public final getClass method. It returns the runtime class of its non-null receiver. For example, an Object reference containing a String returns String.class. A class literal such as Object.class names that specific type regardless of any reference value.
Answer: It marks an instance field to be omitted by default Java object serialization. It does not erase the value from memory, encrypt it, or automatically affect every persistence framework. Custom serialization code can still explicitly write related information.
Static fields are class state and are not ordinary per-object serialized fields. Serializability and transient do not themselves define an application's database mapping or object equality.
Answer: It is a value that refers to an object or is null. It can be stored in variables, passed as an argument, and returned. Java exposes no general pointer arithmetic for references. Passing a reference copies that value; it does not create an alias to the caller's variable itself.
Answer: A reference field receives the default value null before explicit initialization. A field initializer or constructor can replace it; a constructor need not create a new object if another reference is assigned. Reading an unassigned local variable is different and is generally a compile-time error.
A blank final reference field must satisfy definite assignment before normal construction completes. It cannot simply rely on the default null value as though explicitly assigned.
Answer: It must implement all remaining abstract methods with compatible signatures and access, or inherit valid implementations. Otherwise it must itself be abstract. Superclass constructors initialize the inherited state, but constructors are not inherited and cannot be overridden.
Answer: You can supply a Runnable to a Thread or thread builder, or use an executor. Starting a thread schedules its work; calling run directly does not. isAlive is true after a successful start and before termination, although very short tasks may finish before a caller observes them.
Java SE 25 supports platform and virtual threads. Each Thread can be started only once. Prefer separating task logic from lifecycle management rather than subclassing Thread unnecessarily.
Answer: An ordinary constructor has its class's name and no return type. It can have access modifiers, parameters, and a final varargs parameter, but cannot be static, final, or abstract. Constructors can be overloaded and delegate with this(...) or super(...).
Java 25 permits a restricted prologue before an explicit constructor invocation, such as parameter validation. The old rule that super(...) must always be the first statement is no longer generally correct. Early-construction restrictions prevent unsafe use of the under-construction instance. Record and enum constructors have additional rules.
References: Java SE 25 Language Specification, SortedSet, SortedMap, Thread, Serializable.