2011年JAVA认证模拟题第二阶段(24)
Q70.What kind of stream is the System.out object?a. java.io.BufferedWriter
b. java.io.PrintStream
c. java.io.FileWriter
d. java.io.OutputStreamWriter
Q71.Which of the following events has a matching adapter class that implements the appropriate listener interface? Select all correct answers.
a. java.awt.event.MouseEvent
b. java.awt.event.ActionEvent
c. java.awt.event.FocusEvent
d. java.awt.event.ItemEvent
Q72.Here is a partial listing of a class to represent a game board in a networked game. It is desired to prevent collisions due to more than one Thread using the addPic method to modify the array of Image references.
1. class Board extends Object {
2. Image[] pics = new Image;
3. int active = 0;
4. public boolean addPic( Image mg, int pos) {
5. synchronized (this) {
6. if (pics == null)
7. { active++ ; pics = mg; return true; }
8. else
9. return false;
10. }
11. }
12. // remainder of class
Select all the alternatives for line 5 that would accomplish this.
a. synchronized (this)
b. synchronized (pics)
c. synchronized (mg)
d. synchronized (active)
70. b
71. ac
72. ab
页:
[1]