Hi All,
While taking one of the parctice
test I stuck in the following code. Can anybody help me to figure the correct amswer:
FileOutputStream f=new FileOutputStream("TestSerial");
List alist=new ArrayList();
/* .. ....... */
// Serialize list 'alist' and all its contents to stream f.
// Blank
Which one of the following lines of code will serialize list 'alist' and all its contents to FileOutputStream f when substituted for Blank Line in the code above?
Ans. 1. new ObjectOutputStream(f).writeObject(alist);
2. f.write(new ByteOutputStream(alist);
3. new BufferedOutputStream(f).write(alist.toStream());
4. Object.writeObjectToStream(f,alist);
5. alist.writeToByteStream(new ByteOutputStream(f));
Thanks in advance
Akash