Java Reference
In-Depth Information
HTML forms are a common mechanism to input user-specified data into a
JSP application.
Java code is added to a JSP page through directive , expression , declaration , and scriptlet tags.
Answers to Self-Test Exercises
1. The invocation of Thread.sleep takes place inside a thread. Every action in Java
takes place inside some thread. Any action performed by a method invocation in
a specific thread takes place in that thread. Even if it does not know where it is,
a method's action takes place where the method invocation is; if you are lost and
yell out, you might not know where you are but the yell would still be wherever it
is you are.
2. The class Packer inherits the method start from the base class Thread and is
not overridden. The method start invokes the method run , but when start is
invoked by an object of the class Packer , it is the definition of run that is given in
the class Packer that is used, not the definition of run given in the definition of
Thread . That is exactly what is meant by late binding or polymorphism .
3. In this program, the code that runs in each thread is fairly short. As a result, there
is a good chance that each thread runs to completion before the next thread begins.
The sleep method forces a thread to suspend and another thread to begin. This
increases the likelihood that there will be contention for the shared variable and a
race condition.
4. The code synchronizes access to the shared variable but the main method does not
wait for all threads to finish before printing out the value of the shared variable.
Thus, it is possible that main will output a premature value of counter if main
completes before any one of the threads that it creates. To correct this problem,
invoke the join() method on each thread before outputting counter as illustrated
in Display 19.5 .
5. A port is used to identify which program should receive data from the network.
One program only may be bound to a specific port.
6. Each client connection may run in its own thread, requiring a large amount of
memory, disk space, or processor time.
7 . Persistence means that a component's state can be saved so that the next time it is
used it remembers what state it was in.
8. The same one that is used for Swing and AWT.
9. SELECT Result.Title, Names.Author, Result.Author_ID
FROM Result, Names
WHERE Result.Author_ID = Names.Author_ID
10. A connection string is used to connect to (and possibly create) a database via
JDBC. The protocol, database name, and other parameters (such as the username,
password, or flag to create a new database) are specified in the connection string.
11. The execute method can be used to execute any SQL statement, but it is generally
used for SQL commands where return values are not needed. It returns a Boolean
 
Search WWH ::




Custom Search