IO/Serialization Flashcards

1
Q

How do you serialize/deserialize an object in java?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Marker interface? What does a Serializable interface do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are transient variables?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Difference between FileReader and Buffered Reader?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

List some methods in the Scanner class

A
next()
nextLine()
nextInt()
nextBoolean()
nextDouble()
nextShort()
nextFloat()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly