What will be the output of the following Java program?
import java.io.FileOutputStream;
public class FileOutputStreamExample
{
public static void main(String args[])
{
try
{
FileOutputStream fout=new FileOutputStream("D:\\example.txt");
String s="Welcome to India.";
byte b[]=s.getBytes();//converting string into byte array
fout.write(b);
fout.close();
System.out.println("Success");
} catch(Exception e){System.out.println(e);}
}
}
import java.io.FileOutputStream;
public class FileOutputStreamExample
{
public static void main(String args[])
{
try
{
FileOutputStream fout=new FileOutputStream("D:\\example.txt");
String s="Welcome to India.";
byte b[]=s.getBytes();//converting string into byte array
fout.write(b);
fout.close();
System.out.println("Success");
} catch(Exception e){System.out.println(e);}
}
}A. "Success" to the output and "Welcome to India" to the file
B. only "Welcome to India" to the file
C. compile time error
D. No Output
Answer: Option A
A. The process of converting an object into a byte stream
B. The process of converting a byte stream into an object
C. The process of converting an object into a text file
D. The process of converting a text file into an object
Which interface in Java is used to mark a class as serializable?
A. `MarkSerializable`
B. `SerializableClass`
C. `Serialize`
D. `Serializable`
What is the purpose of the `ObjectOutputStream` class in Java Serialization?
A. To read objects from an input stream
B. To convert objects to text format
C. To write objects to an output stream
D. To serialize primitive data types
A. It indicates that the variable is mandatory for serialization
B. It indicates that the variable should not be serialized
C. It indicates that the variable should be ignored during deserialization
D. None of These

Join The Discussion