226. What is the difference between exception and error?- The exception class
defines mild error conditions that your program encounters. Exceptions can occur
when trying to open the file, which does not exist, the network connection is
disrupted, operands being manipulated are out of prescribed ranges, the class file
you are interested in loading is missing. The error class defines serious error
conditions that you should not attempt to recover from. In most cases it is
advisable to let the program terminate when such an error is encountered.
227. What is the difference between process and thread?- Process is a program in
execution whereas thread is a separate path of execution in a program.
228. What is multithreading and what are the methods for inter-thread
communication and what is the class in which these methods are defined?-
Multithreading is the mechanism in which more than one thread run independent of
each other within the process. wait (), notify () and notifyAll() methods can be
used for inter-thread communication and these methods are in Object class. wait() :
When a thread executes a call to wait() method, it surrenders the object lock and
enters into a waiting state. notify() or notifyAll() : To remove a thread from the
waiting state, some other thread must make a call to notify() or notifyAll() method
on the same object.
229. What is the class and interface in java to create thread and which is the
most advantageous method?- Thread class and Runnable interface can be used to
create threads and using Runnable interface is the most advantageous method to
create threads because we need not extend thread class here.
230. What are the states associated in the thread?- Thread contains ready,
running, waiting and dead states.
Saturday, May 10, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment