Menu
Topics Index
...
`

ObjectOutputStream


If you need explanation Read this topic

If you need Answer Take test on this topic

ObjectOutputStream
What will be the output of following program?
import java.io.*;

class Student implements Serializable {
    int id;
    String name;
    transient int age;
    public Student(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }
}
class Prakasam {
    public static void main(String args[]) throws Exception {
        Student s1 = new Student(211, "ravi", 22);
        FileOutputStream f = new FileOutputStream("f.txt");
        ObjectOutputStream out = new ObjectOutputStream(f);
        out.writeObject(s1);
        out.flush();
        System.out.println("success");
    }
}

A. 211, ravi, 22
B. success
C. 211, ravi, 22
success
D. Some other output
E. Output can not be determined
F. Compilation Error or Runtime Error
Topic: Java ObjectOutputStream

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ANS is B.
object s1 is written in file "f,txt" and "success" get printed

Posted by Mânïshå Mùlchåndânï    2014-06-26 08:33:05


ans is:A

Posted by Adithya Aleti    2014-06-26 08:39:15


ans b..studnt class nt a public type .
sudent objct creatd in othr class .
prints sucess..s1 object strd in f.txt

Posted by Maheshwari Natarajan    2014-06-26 08:49:38


Ans is c...first the content of the file get printed and the string success get printed

Posted by Badam Swathi    2014-06-26 12:25:23


Congratulations Maheshwari Natarajan. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-06-27 04:21:12


© meritcampus 2019

All Rights Reserved.

Open In App