IO/Serialization Flashcards
How do you serialize/deserialize an object in java?
You must first implement the java.io.Serializable interface. The ObjectOutputStream class contains the writeobject()/writeobject(Object objName) and readobject() method for serializing/deserializing an object, respectively.
What is a Marker interface? What does a Serializable interface do?
A marker interface is an empty interface (no fields or methods). The Serializable interface is used to make an object eligible for saving its state into a file
What are transient variables?
A transient variable indicates to the JVM that it is not part of the persistent state of an object/ The modifier transient can be applied to the field members of a class to turn off serialization for those members
Difference between FileReader and Buffered Reader?
Filereader is used to read a file from a disk drive, whereas bufferReader is not bound to only reading files. It can be used to read data from any character stream
List some methods in the Scanner class
next() nextLine() nextInt() nextBoolean() nextDouble() nextShort() nextFloat()