Question: What is the package?
Answer: The package is a Java namespace or part of Java libraries. The Java
API is grouped into libraries of related classes and interfaces; these libraries
are known as packages.
Question: What is native code?
Answer: The native code is code that after you compile it, the compiled code
runs on a specific hardware platform.
Question: Is Java code slower than native code?
Answer: Not really. As a platform-independent environment, the Java platform
can be a bit slower than native code. However, smart compilers, well-tuned
interpreters, and just-in-time bytecode compilers can bring performance close to
that of native code without threatening portability.
Question: What is the serialization?
Answer: The serialization is a kind of mechanism that makes a class or a
bean persistence by having its properties or fields and state information saved
and restored to and from storage.
Question: How to make a class or a bean serializable?
Answer: By implementing either the java.io.Serializable interface, or the
java.io.Externalizable interface. As long as one class in a class's inheritance
hierarchy implements Serializable or Externalizable, that class is serializable
Question: How many methods in the Serializable interface?
Answer:There is no method in the Serializable interface. The Serializable
interface acts as a marker, telling the object serialization tools that your
class is serializable.
Question: . How many methods in the Externalizable interface?
Answer: There are two methods in the Externalizable interface. You have to
implement these two methods in order to make your class externalizable. These
two methods are readExternal() and writeExternal().
Question: What is the difference between Serializalble and
Externalizable interface?
Answer: When you use Serializable interface, your class is serialized
automatically by default. But you can override writeObject() and readObject()
two methods to control more complex object serailization process. When you use
Externalizable interface, you have a complete control over your class's
serialization process.
Question: What is a transient variable?
Answer: A transient variable is a variable that may not be serialized. If you
don't want some field to be serialized, you can mark that field transient or
static.
Question: Which containers use a border layout as their
default layout?
Answer: The Window, Frame and Dialog classes use a border layout as their
default layout.
Question: . How are Observer and Observable used?
Answer: Objects that subclass the Observable class maintain a list of observers.
When an Observable object is updated it invokes the update() method of each of
its observers to notify the observers that it has changed state. The Observer
interface is implemented by objects that observe Observable objects.
Question: What is synchronization and why is it important?
Answer: 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.
Question: What are synchronized methods and synchronized
statements?
Answer: 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.
Question: How are Observer and Observable used?
Answer: Objects that subclass the Observable class maintain a list of observers.
When an Observable object is updated it invokes the update() method of each of
its observers to notify the observers that it has changed state. The Observer
interface is implemented by objects that observe Observable objects.
Question: What is synchronization and why is it important?
Answer: 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.
Question: What are synchronized methods and
synchronized statements?
Answer: 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.
Question: What are three ways in which a thread can
enter the waiting state?
Answer: A thread can enter the waiting state by invoking its sleep() method,
by blocking on I/O, 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.
NEXT