Friday, May 2, 2008

Java Interview Questions 12

56: What type of parameter passing does Java support?
A: In Java the arguments are always passed by value .

57: Primitive data types are passed by reference or pass by value?
A: Primitive data types are passed by value.

58: Objects are passed by value or by reference?
A: Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object .

59: What is serialization?
A: Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.

60: How do I serialize an object to a file?
A: The class whose instances are to be serialized should implement an interface Serializable. Then you pass the instance to the ObjectOutputStream which is connected to a fileoutputstream. This will save the object to a file.

No comments:

Useful Information