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

Why to use nested classes in java? (Or) what is the purpose of nested class in java?

0 Answers  


What is variable argument in java?

0 Answers  


Why do we create threads in java?

0 Answers  


Name the packages in JDK?

2 Answers  


What is the difference between array and arraylist? what is the difference between arraylist and linkedlist?

8 Answers   EDS, Matrix,


Describe string intern() methodology

0 Answers  


What is difference between == equals () and compareto () method?

0 Answers  


Why parameters should be passed by reference?

0 Answers  


Is string a keyword in java?

1 Answers  


Explain where variables are created in memory?

0 Answers  


What are recursive functions? Give some examples?

0 Answers   Axtria, ITC Indian Tobacco Company,


they asked class A{} class B{} class c{} all the three class saved as a single file,there is no main method in the file and anothe class M.java class m { psvm(String args[]) { // here the parent class can access } }

2 Answers   DNS, IPSR Solutions,


Categories