Govt. Exams
Entrance Exams
Streams are not thread-safe. Concurrent access by multiple threads can lead to data corruption. Synchronization or separate streams per thread are needed.
InvalidClassException is thrown when serialVersionUID doesn't match during deserialization, indicating class incompatibility.
BufferedReader.readLine() is the most efficient way to read complete lines as it buffers input and provides a dedicated method for line reading.
mark() records the current position in the stream, and reset() returns to that marked position, useful for lookahead operations.
SequenceInputStream concatenates multiple input streams, reading from them sequentially as if they were a single stream.
GZIPInputStream decompresses GZIP-compressed data, allowing transparent reading of compressed files as normal streams.
The transient keyword marks fields that should not be serialized, useful for excluding sensitive data or non-serializable objects.
BufferedReader combined with custom parsing logic (using split or regex) handles variable-length fields better than fixed-format alternatives.
The unread() method of PushbackInputStream allows you to push bytes back into the stream so they can be read again.
PrintWriter is synchronized, making it thread-safe. Other stream classes are not inherently thread-safe and require external synchronization in multi-threaded contexts.