Saturday, May 10, 2008

Java Interview Questions 47

231. What is synchronization?-
Ans. Synchronization is the mechanism that ensures that only one thread is accessed the resources at a time.

232. When you will synchronize a piece of your code?- When you expect your code
will be accessed by different threads and these threads may change a particular
data causing data corruption.

233. What is deadlock?- When two threads are waiting each other and can’t
precede the program is said to be deadlock.

234. What is daemon thread and which method is used to create the daemon
thread?- Daemon thread is a low priority thread which runs intermittently in the
back ground doing the garbage collection operation for the java runtime system.
setDaemon method is used to create a daemon thread.

235. Are there any global variables in Java, which can be accessed by other part
of your program?- No, it is not the main method in which you define variables.
Global variables is not possible because concept of encapsulation is eliminated
here.

No comments:

Useful Information