MAX_PRIORITY which is 10, MIN_PRIORITY which is 1, NORM_PRIORITY which is 5.
32. What is the use of synchronizations?
Every object has a lock, when a synchronized keyword is used on a piece of code the, lock must be obtained by the thread first to execute that code, other threads will not be allowed to execute that piece of code till this lock is released.
33. What are synchronized methods and synchronized statements?
Synchronized methods are methods that are used to control access to an object. For example, 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.
34. What are different ways in which a thread can enter the waiting state?
A thread can enter the waiting state by invoking its sleep() method, blocking on I/O, unsuccessfully attempting to acquire an object’s lock, or invoking an object’s wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.
35. Can a lock be acquired on a class?
Yes, a lock can be acquired on a class. This lock is acquired on the class’s Class object.
36. What’s new with the stop(), suspend() and resume() methods in new JDK 1.2?
The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.
37. What is the preferred size of a component?
The preferred size of a component is the minimum component size that will allow the component to display normally.
38. What method is used to specify a container’s layout?
The setLayout() method is used to specify a container’s layout. For example, setLayout(new FlowLayout()); will be set the layout as FlowLayout.
39. Which containers use a FlowLayout as their default layout?
The Panel and Applet classes use the FlowLayout as their default layout.
40. What state does a thread enter when it terminates its processing?
When a thread terminates its processing, it enters the dead state.