Java Reference
In-Depth Information
9 . What type of stream is System.in ?
InputStream
10 . What does the read( ) method of InputStream return when the end of the stream is
reached?
-1
11 . What type of stream is used to read binary data?
DataInputStream
12 . Reader and Writer are at the top of the ____________ class hierarchies.
character-based I/O
13 . The try -with-resources statement is used for ___________ ____________
____________.
automatic resource management
14 . If you are using the traditional method of closing a file, then closing a file within a fi-
nally block is generally a good approach. True or False?
True
Chapter 11: Multithreaded Programming
1 . How does Java's multithreading capability enable you to write more efficient pro-
grams?
Multithreading allows you to take advantage of the idle time that is present in nearly
all programs. When one thread can't run, another can. In multicore systems, two or
more threads can execute simultaneously.
2 . Multithreading is supported by the __________ class and the __________ interface.
Multithreading is supported by the Thread class and the Runnable interface.
3 . When creating a runnable object, why might you want to extend Thread rather than
implement Runnable ?
You will extend Thread when you want to override one or more of Thread 's meth-
ods other than run( ) .
4 . Show how to use join( ) to wait for a thread object called MyThrd to end.
Search WWH ::




Custom Search