Thursday, May 29, 2008

Java Interview Questions 21

101: Can an unreachable object become reachable again?
A: An unreachable object may become reachable again. This can happen when the object's finalize() method is invoked and the object performs an operation which causes it to become accessible to reachable objects.

102: What method must be implemented by all threads?
A: All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.

103: What are synchronized methods and synchronized statements?
A: Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

104: What is Externalizable?
A: Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in)

105: What modifiers are allowed for methods in an Interface?
A: Only public and abstract modifiers are allowed for methods in interfaces.

No comments:

Useful Information