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

Answers were Sorted based on User's Feedback



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

Answer / s.ramesh

We have to implement serializable interface

Is This Answer Correct ?    2 Yes 0 No

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

Answer / 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

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

Answer / puneet

outpurstreamobject.writeobject(object o);
flush//;
close//;

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More Core Java Interview Questions

How strings are created in java?

0 Answers  


what is comparable and comparator interface?

0 Answers  


What are the super most classes for all the streams?

0 Answers  


What is primitive data type in java?

0 Answers  


What is the hashcode () and equals () used for?

0 Answers  






What is the use of 'super' keyword inside a constructor?

0 Answers   Flextronics, Thomson Reuters, Virtusa,


What is the base class in java from which all classes are derived?

0 Answers  


what is the main class of all the classes

5 Answers   Photon,


what is webservices?

1 Answers   CTS, Ericsson, HCL,


Why do we need wrapper class?

0 Answers  


JVM responsibility?

6 Answers   TCS,


List the different types of classloaders in java.

0 Answers  


Categories