613). Which of these is a process of extracting/removing the state of an object from a stream?

[A]Serialization
[B]Externalization
[C]File Filtering
[D]Deserialization

Show Answer

614). Which of these process occur automatically by java run time system?

[A]Serialization
[B]Memory allocation
[C]Deserialization
[D]All of the mentioned

Show Answer

615). Which of these interface extends DataInput interface?

[A]Serializable
[B]Externalization
[C]ObjectOutput
[D]ObjectInput

Show Answer

617). Which of these class extend InputStream class?

[A]ObjectStream
[B]ObjectInputStream
[C]ObjectOutput
[D]ObjectInput

Show Answer

618). What will be the output of the following Java code?

[A]5
[B]void
[C]serialization
[D]deserialization

Show Answer

619). What will be the output of the following Java code?
    import java.io.*;
    class serialization
    {
        public static void main(String[] args)
        {
            try
            {
	        Myclass object1 = new Myclass("Hello", -7, 2.1e10);
	        FileOutputStream fos = new FileOutputStream("serial");
	        ObjectOutputStream oos = new ObjectOutputStream(fos);
	        oos.writeObject(object1);
	        oos.flush();
	        oos.close();
	    }
	    catch(Exception e)
            {
	        System.out.println("Serialization" + e);
                System.exit(0);
            }
	    try
            {
	        int x;
	        FileInputStream fis = new FileInputStream("serial");
	        ObjectInputStream ois = new ObjectInputStream(fis);
	        x = ois.readInt();
	        ois.close();
	        System.out.println(x);		    	
	    }
	    catch (Exception e)
            {
                System.out.print("deserialization");
	        System.exit(0);
	    }
        }
    }
    class Myclass implements Serializable
    {
	String s;
	int i;
	double d;
	Myclass(String s, int i, double d)
        {
	    this.d = d;
	    this.i = i;
	    this.s = s;
	}
    }

[A]-7
[B]Hello
[C]2.1E10
[D]deserialization

Show Answer

620). What will be the output of the following Java program?
    import java.io.*;
    class streams
    {
        public static void main(String[] args)
        {
            try
            {
	        FileOutputStream fos = new FileOutputStream("serial");
	        ObjectOutputStream oos = new ObjectOutputStream(fos);
	        oos.writeFloat(3.5);
	        oos.flush();
	        oos.close();
	    }
	    catch(Exception e)
            {
	        System.out.println("Serialization" + e);
                System.exit(0);
            }
	    try
            {
	        FileInputStream fis = new FileInputStream("serial");
	        ObjectInputStream ois = new ObjectInputStream(fis);
	        ois.close();
	        System.out.println(ois.available());		    	
	    }
	    catch (Exception e)
            {
                System.out.print("deserialization");
	        System.exit(0);
	    }
        }
    }

[A]1
[B]2
[C]3
[D]0

Show Answer

621). What will be the output of the following Java program?
    import java.io.*;
    class streams
    {
        public static void main(String[] args)
        {
            try
            {
	        FileOutputStream fos = new FileOutputStream("serial");
	        ObjectOutputStream oos = new ObjectOutputStream(fos);
	        oos.writeFloat(3.5);
	        oos.flush();
	        oos.close();
	    }
	    catch(Exception e)
            {
	        System.out.println("Serialization" + e);
                System.exit(0);
            }
	    try
            {
	        FileInputStream fis = new FileInputStream("serial");
	        ObjectInputStream ois = new ObjectInputStream(fis);
	        System.out.println(ois.available());		    	
	    }
	    catch (Exception e) 
            {
                System.out.print("deserialization");
	        System.exit(0);
	    }
        }
    }

[A]1
[B]2
[C]3
[D]4

Show Answer

622). 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:\\sanfoundry.txt");    
             String s="Welcome to Sanfoundry.";    
             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 Sanfoundry” to the file
[B]only “Welcome to Sanfoundry” to the file
[C]compile time error
[D]No Output

Show Answer