Wednesday, May 7, 2008

Java Interview Questions 31

151. How many methods in the Serializable interface?
Answer:There is no method in the Serializable interface. The Serializable interface
acts as a marker, telling the object serialization tools that your class is
serializable.

152. How many methods in the Externalizable interface?
Answer: There are two methods in the Externalizable interface. You have to
implement these two methods in order to make your class externalizable. These two
methods are readExternal() and writeExternal().

153. What is the difference between Serializalble and Externalizable
interface?
Answer: When you use Serializable interface, your class is serialized automatically
by default. But you can override writeObject() and readObject() two methods to
control more complex object serailization process. When you use Externalizable
interface, you have a complete control over your class's serialization process.

154. What is a transient variable?
Answer: A transient variable is a variable that may not be serialized. If you don't
want some field to be serialized, you can mark that field transient or static.

155. Which containers use a border layout as their default layout?
Answer: The Window, Frame and Dialog classes use a border layout as their default
layout.

No comments:

Useful Information