-
What is the output of this program?
import java.io.*;
public class streams_Example
{
public static void main(String[] args)
{
try
{
FileOutputStream FOS = new FileOutputStream("serial");
ObjectOutputStream OOS = new ObjectOutputStream(FOS);
OOS.writeDouble(1.5);
OOS.flush();
OOS.close();
}
catch(Exception e)
{
System.out.println("Serialization" + e);
System.exit(0);
}
try
{
float p;
FileInputStream FIS = new FileInputStream("serial");
ObjectInputStream OIS = new ObjectInputStream(FIS);
p = OIS.readInt();
OIS.close();
System.out.println(p);
}
catch (Exception e)
{
System.out.print("deserialization");
System.exit(0);
}
}
}
-
- 1.07
- 1.07321754E9
- 1.07321
- 2.07321754E9
- None of these
Correct Option: B
OOS.writeFloat(1.5); writes in output stream which is extracted by p = OIS.readInt(); and stored in p hence p contains 1.5.