I have a Person object with 5 variables and I want to store
them in a file called Person.txt. What should I do?

Answer Posted / srinu

we have imlpement ur class with java.lang.Serializible
interface and used the following steps
1)ObjectOutPutStream class(one method is their write objects
into file)
(a)writeObject(Object obj) -------> writing for objects
into file.This process is called Serializtion.

2)ObjectInputStream class reading the objects from file
(a)readObject(Object obj)---------> Reading objects from
fole This process is called Deserialization.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Java is Pass by Value or Pass by Reference?

614


What is final method in java?

535


What is starvation?

676


What is the exact difference in between unicast and multicast object? Where we will use?

552


What are the types of collections in java?

532






What is static import?

588


What is private protected in java?

543


What are voids?

528


What is a parameter in a function?

524


What are the difference between composition and inheritance in java?

506


Can you give names of Container classes?

1844


What is append function?

561


What is return type in java?

626


What is a dot notation?

542


Explain about main thread in java?

606