Question 1
Which two statements about Java serialization and stream buffering are correct? (Choose two.)
A. Declaring a private static final long serialVersionUID lets a class control serialization version compatibility across changesCorrect answer
serialVersionUID is an optional private static final long that pins a class's serialization version; matching IDs let a changed class deserialize old data, while mismatched IDs cause InvalidClassException, making it the developer's version-compatibility control.
B. Bytes written to a BufferedOutputStream may stay in the buffer and not reach the destination until flush() or close() is calledCorrect answer
A BufferedOutputStream accumulates bytes in memory and only forwards them to the wrapped stream when the buffer fills, or when flush() or close() is called; without one of those, buffered bytes can be lost.
C. Marking a field static causes it to be written as part of each object's serialized state
static fields belong to the class, not to any instance, so they are never part of an object's serialized state; only instance, non-transient fields are written.
D. A class must implement Externalizable before ObjectOutputStream can serialize it
Implementing Serializable is sufficient; Externalizable is an optional alternative that gives full manual control, not a prerequisite for serialization.
Explanation
Default serialization writes only an object's instance, non-transient fields; static and transient fields are excluded. serialVersionUID is an optional marker that pins the serialization version so a changed class can still read old data, while a mismatch raises InvalidClassException. Separately, buffered output streams hold bytes until the buffer fills or an explicit flush/close occurs, which is exactly why the try-with-resources idiom (whose close flushes) is the safe pattern.