I) In Java, which statements ARE true?
1. When a thread sleeps, its locks are released
2. If a class has synchronized code, multiple threads can still access the non synchronized code.
3. Methods and variables can be protected from concurrent access problems by ing them with the synchronized keyword.
4. When a thread invokes wait(), its locks are released.
5. A static method cannot be synchronizedJ) Which TWO combinations below consist (and only) the necessary classes in package java.io to read a single line of Traditional Chinese text via TCP connections?
I. Socket
II. TCPSocket
III. PipedInputStream
IV. BufferedInputStream
V. BufferedReader
VI. InputStreamReader
VII. LineNumberReader
VIII. StringReader1. (I) + (III) + (VI) + (VII)
2. (I) + (IV) + (VI) + (V)
3. (II) + (VI) + (VII)
4. (I) + (IV) + (VI) + (VII)
5. (I) + (VI) + (VIII)
1. When a thread sleeps, its locks are released
2. If a class has synchronized code, multiple threads can still access the non synchronized code.
3. Methods and variables can be protected from concurrent access problems by ing them with the synchronized keyword.
4. When a thread invokes wait(), its locks are released.
5. A static method cannot be synchronizedJ) Which TWO combinations below consist (and only) the necessary classes in package java.io to read a single line of Traditional Chinese text via TCP connections?
I. Socket
II. TCPSocket
III. PipedInputStream
IV. BufferedInputStream
V. BufferedReader
VI. InputStreamReader
VII. LineNumberReader
VIII. StringReader1. (I) + (III) + (VI) + (VII)
2. (I) + (IV) + (VI) + (V)
3. (II) + (VI) + (VII)
4. (I) + (IV) + (VI) + (VII)
5. (I) + (VI) + (VIII)
第二题:
Socket 要有的
BufferedInputStream 缓冲接收
InputStreamReader 包装转换字节流为字符流
BufferedReader 包装,可以整行读取