Q11. Name the container which uses Border Layout as their default layout?
A container which
uses Border Layout as their default are: window, Frame and Dialog classes.
Q12. What do you understand by Synchronization?
Synchronization is a
process of controlling the access of shared resources by the multiple threads
in such a manner that only one thread can access one resource at a time. In non
synchronized multithreaded application, it is possible for one thread to modify
a shared object while another thread is in the process of using or updating the
object's value.
Synchronization
prevents such type of data corruption.
E.g. Synchronizing a
function:
public synchronized
void Method1 () {
// Appropriate
method-related code.
}
E.g. Synchronizing a
block of code inside a function:
public myFunction
(){
synchronized (this)
{
// Synchronized code
here.
}}
Q13. What is synchronization and why is it important?
With respect to
multithreading, synchronization is the capability to control the access of multiple
threads to shared resources. Without synchronization, it is possible for one thread
to modify a shared object while another thread is in the process of using or updating
that object's value. This often causes dirty data and leads to significant
errors.
Q14. What are synchronized methods and synchronized statements?
Synchronized methods
are methods that are used to control access to a method or 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.
Q15. What are three ways in which a thread can enter the waiting state?
A thread can enter
the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully
attempting to acquire an object's lock, or by invoking an object's wait() method.
It can also enter the waiting state by invoking its (deprecated) suspend()
method.
Q16. 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.
Q17. What's new with the stop(), suspend() and resume() methods in JDK 1.2?
The stop(),
suspend() and resume() methods have been deprecated in JDK 1.2.
Q18. 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.
Q19. What would you use to compare two String variables - the operator == or the method equals()?
I'd use the method
equals() to compare the values of the Strings and the == to check if two
variables point at the same instance of a String object.
Q20. What is thread?
A thread is an
independent path of execution in a system.
No comments:
Post a Comment