复习测试

复习测试

1、单选题:
‎What is best to describe the relationship between Component and Font?‌
选项:
A: Association
B: Aggregation
C: Composition
D: Inheritance
E: 244
答案: 【 Association

2、单选题:
下面三个表达式中,正确的是 ___________.

1. frame.setLocationRelativeTo(null);
2. frame.setSize(100, 200);
3. frame.setVisible(true);
选项:
A: 1 2 3
B: 1 3 2
C: 2 1 3
D: 3 2 1
E: 245
答案: 【 2 1 3

3、单选题:
How many frames are displayed?

import javax.swing.*;

public class Test extends JFrame {
public static void main(String[] args) {
JFrame f1 = new Test();
JFrame f2 = new Test();
JFrame f3 = new Test();
f1.setVisible(true);
f2.setVisible(true);
f3.setVisible(true);
}
}
选项:
A: 1
B: 2
C: 3
D: 0
E: 246
答案: 【 3

4、单选题:
Jpanel的缺省布局方式是__________________.
选项:
A: FlowLayout
B: GridLayout
C: BorderLayout
D: None
E: 247
答案: 【 FlowLayout

5、单选题:
方法________________将给Jpanel p增加一个组件 c。
选项:
A: p.add(c)
B: p.getContentPane(c)
C: p.insert(c)
D: p.append(c)
E: 248
答案: 【 p.add(c)

6、单选题:
Analyze the following code:

import javax.swing.*;

public class Test extends JFrame {
private JButton jbtOK = new JButton("OK");

public static void main(String[] args) {
// Create a frame and set its properties
JFrame frame = new Test();
frame.setTitle("Logic Error");
frame.setSize(200, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}

public Test() {
jbtOK.setToolTipText("This is a button");
add(new JButton("OK"));
}
}
选项:
A: The tool tip text is displayed when you move the mouse on the button.
B: The tool tip text will be displayed if you replace add(new JButton("OK")) with add(jbtOK).
C: The tool tip text will be displayed if you swap the two lines in the Test constructor.
D: The tool tip text will be displayed if you replace add(new JButton("OK")) with add(jbtOK = new JButton("OK")).
E: 249
答案: 【 The tool tip text will be displayed if you replace add(new JButton("OK")) with add(jbtOK).

7、单选题:
Show the output of the following code?

import javax.swing.*;

public class Test {
public static void main(String[] args) {
JButton jbtOK = new JButton("OK");
System.out.print(jbtOK.isVisible() + ", ");

JFrame frame = new JFrame();
System.out.println(frame.isVisible());
}
}
选项:
A: true, true
B: true, false
C: false, true
D: false, false
E: 250
答案: 【 true, false

8、单选题:
方法_________设置按钮jbt上的文字放在图标的右边。
选项:
A: jbt.setVerticalTextPosition(JButton.LEFT)
B: jbt.setHorizontalTextPosition(JButton.LEFT)
C: jbt.setHorizontalTextPosition(JButton.RIGHT)
D: jbt.setHorizontalAlignment(JButton.RIGHT)
E: 251
答案: 【 jbt.setHorizontalTextPosition(JButton.RIGHT)

9、单选题:
The method __________ specifies that the text and icon are horizontally aligned to the right in the button jbt.
选项:
A: jbt.setVerticalTextPosition(JButton.LEFT)
B: jbt.setHorizontalTextPosition(JButton.LEFT)
C: jbt.setHorizontalTextPosition(JButton.RIGHT)
D: jbt.setHorizontalAlignment(JButton.RIGHT)
E: 252
答案: 【 jbt.setHorizontalAlignment(JButton.RIGHT)

10、单选题:
Analyze the following code:

import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;

public class Test extends JFrame {
public Test() {
Border border = new TitledBorder("My button");
JButton jbt1 = new JButton("OK");
JButton jbt2 = new JButton("Cancel");
jbt1.setBorder(border);
jbt2.setBorder(border);
add(jbt1, BorderLayout.NORTH);
add(jbt2, BorderLayout.SOUTH);
}

public static void main(String[] args) {
JFrame frame = new Test();
frame.setSize(200, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
选项:
A: Two buttons displayed with the same border.
B: Two buttons displayed, but only one button has the border.
C: The program has a compile error because you assign new TitledBorder("My button") to a variable of the Border type.
D: The program has a runtime error because you cannot set a border on a button.
E: 253
答案: 【 Two buttons displayed with the same border.

11、单选题:
方法___________将获取标签jlbl上的文本。
选项:
A: jlbl.text()
B: jlbl.getText()
C: jlbl.findText()
D: jlbl.retrieveText().
E: 254
答案: 【 jlbl.getText()

12、单选题:
The method __________ specifies that the text is placed on the right of the icon in the label jlbl.
选项:
A: jlbl.setVerticalTextPosition(JButton.LEFT)
B: jlbl.setHorizontalTextPosition(JButton.LEFT)
C: jlbl.setHorizontalTextPosition(JButton.RIGHT)
D: jlbl.setHorizontalAlignment(JButton.RIGHT)
E: 255
答案: 【 jlbl.setHorizontalTextPosition(JButton.RIGHT)

13、单选题:
___________能够输入或者显示一个字符串。
选项:
A: A label
B: A button
C: A check box
D: radio button
E: 256
答案: 【 256

14、单选题:
一个字节包含 ________ 位
选项:
A: 4
B: 8
C: 12
D: 16
E: 1
答案: 【 8

15、单选题:
方法__________用来获取文本控件jtf上的内容。
选项:
A: jtf.getText(s)
B: jtf.getText()
C: jtf.getString()
D: jtf.findString()
E: 257
答案: 【 jtf.getText()

16、单选题:
Which of the following statements is correct?
选项:
A: Every line in a program must end with a semicolon
B: Every statement in a program must end with a semicolon
C: Every comment line must end with a semicolon
D: Every method must end with a semicolon
E: 2
答案: 【 Every statement in a program must end with a semicolon

17、单选题:
The method __________ appends a string s into the text area jta.
选项:
A: jta.setText(s)
B: jta.appendText(s)
C: jta.append(s)
D: jta.insertText(s)
E: 258
答案: 【 jta.append(s)

18、单选题:
java字节码文件的后缀是
选项:
A: .java
B: .obj
C: .class
D: .exe
E: 3
答案: 【 .class

19、单选题:
To wrap a line in a text area jta, invoke ____________.
选项:
A: jta.setLineWrap(false)
B: jta.setLineWrap(true)
C: jta.WrapLine()
D: jta.wrapText()
E: 259
答案: 【 jta.setLineWrap(true)

20、单选题:
Java ___________ can run from a Web browser
选项:
A: applications
B: applets
C: servlets
D: Micro Edition programs
E: 4
答案: 【 applets

复习测验1

1、单选题:
The signature of a method consists of ________
选项:
A: method name
B: method name and parameter list
C: return type, method name, and parameter list
D: parameter list
答案: 【 return type, method name, and parameter list

2、单选题:
Suppose your method does not return any value, which of the following keywords can be used as a return type?
选项:
A: void
B: int
C: double
D: None of the above
答案: 【 void

3、单选题:
Suppose you wish to provide an accessor method for a boolean property finished, what signature of the method should be?
选项:
A: public void getFinished()
B: public boolean getFinished()
C: public boolean isFinished()
D: public void isFinished()
答案: 【 public boolean isFinished()

4、单选题:
Suppose the xMethod() is invoked from a main method in a class as follows, xMethod() is _________ in the class.

public static void main(String[] args) {
xMethod();
}
选项:
A: a static method
B: an instance method
C: a static method or an instance method
D: an Object method
答案: 【 a static method

5、单选题:
Given:
3. public class Dark {
4. int x = 3;
5. public static void main(String[] args) {
6. new Dark().go1();
7. }
8. void go1() {
9. int x;
10. go2(++x);
11. }
12. void go2(int y) {
13. int x = ++y;
14. System.out.println(x);
15. }
16. }
What is the result?
选项:
A: 3
B: 4
C: 5
D: Compilation fails
答案: 【 Compilation fails

6、单选题:
Given:
1. public class Yippee {
2. public static void main(String [] args) {
3. for(int x = 1; x < args.length; x++) {
4. System.out.print(args[x] + " ");
5. }
6. }
7. } and two separate command line invocations: java Yippee
java Yippee 1 2 3 4 What is the result?
选项:
A: No output is produced. 1 2 3
B: No output is produced. 2 3 4
C: No output is produced. 1 2 3 4
D: An exception is thrown at runtime. 1 2 3
答案: 【 No output is produced. 2 3 4

7、单选题:
Given:
1. public class Pass {
2. public static void main(String [] args) {
3. int x = 5;
4. Pass p = new Pass();
5. p.doStuff(x);
6. System.out.print(" main x = " + x);
7. }
8.
9. void doStuff(int x) {
10. System.out.print(" doStuff x = " + x++);
11. }
12. }
What is the result?
选项:
A: doStuff x = 6 main x = 6
B: doStuff x = 5 main x = 5
C: doStuff x = 5 main x = 6
D: doStuff x = 6 main x = 5
答案: 【 doStuff x = 5 main x = 5

8、单选题:
Given:
1. public class Frodo extends Hobbit {
2. public static void main(String[] args) {
3. Short myGold = 7;
4. System.out.println(countGold(myGold, 6));
5. }
6. }
7. class Hobbit {
8. int countGold(int x, int y) { return x + y; }
9. }
What is the result?
选项:
A: 13
B: Compilation fails due to multiple errors
C: Compilation fails due to an error on line 1
D: Compilation fails due to an error on line 4
答案: 【 Compilation fails due to an error on line 4

9、单选题:
Given:
1. public class Batman {
2. int squares = 81;
3. public static void main(String[] args) {
4. new Batman().go();
5. }
6. void go() {
7. incr(++squares);
8. System.out.println(squares);
9. }
10. void incr(int squares) { squares += 10; }
11. }
What is the result?
选项:
A: 81
B: 82
C: 91
D: 92
答案: 【 82

10、单选题:
Given:
1. class Voop {
2. public static void main(String[] args) {
3. doStuff(1);
4. doStuff(1,2);
5. }
6. // insert code here
7. }
Which, inserted independently at line 6, will compile?
选项:
A: static void doStuff(int... doArgs) { }
B: static void doStuff(int[] doArgs) { }
C: static void doStuff(int doArgs...) { }
D: static void doStuff(int... doArgs, int y) { }
答案: 【 static void doStuff(int... doArgs) { }

11、单选题:
Given:
1. class Voop {
2. public static void main(String[] args) {
3. doStuff(1);
4. doStuff(1,2);
5. }
6. // insert code here
7. }
Self Test Answers 79
80 Chapter 1: Declarations and Access Control
Which, inserted independently at line 6, will compile?
选项:
A: static void doStuff(int... doArgs) { }
B: static void doStuff(int[] doArgs) { }
C: static void doStuff(int doArgs...) { }
D: static void doStuff(int... doArgs, int y) { }
答案: 【 static void doStuff(int... doArgs) { }

12、单选题:
Given the following code what will be output?

public class Pass{
static int j=20;
public static void main(String argv[]){
int i=10;
Pass p = new Pass();
p.amethod(i);
System.out.println(i);
System.out.println(j); }

public void amethod(int x)
{ x=x*2; j=j*2; }
}
选项:
A: Error: amethod parameter does not match variable
B: 20 and 40
C: 10 and 40
D: 10 and 20
答案: 【 10 and 40

13、单选题:
Analyze the following code:
class Test {

public static void main(String[] args) {
System.out.println(xMethod((double)5));
}

public static int xMethod(int n) {
System.out.println("int");
return n;
}

public static long xMethod(long n) {
System.out.println("long");
return n;
}
}
选项:
A: The program displays int followed by 5
B: The program displays long followed by 5
C: The program runs fine but displays things other than given in a and b
D: The program does not compile
答案: 【 The program does not compile

14、单选题:
Analyze the following code:

public class Test {
public static void main(String[] args) {
System.out.println(xMethod(5, 500L));
}
public static int xMethod(int n, long l) {
System.out.println("int, long");
return n;
}
public static long xMethod(long n, long l) {
System.out.println("long, long");
return n;
}
}
选项:
A: The program displays int, long followed by 5
B: The program displays long, long followed by 5
C: The program runs fine but displays things other than 5
D: The program does not compile because the compiler cannot distinguish which xmethod to invoke
答案: 【 The program displays int, long followed by 5

15、单选题:
Analyze the following code.

public class Test {
public static void main(String[] args) {
int n = 2;
xMethod(n);

System.out.println("n is " + n);
}

void xMethod(int n) {
n++;
}
}
选项:
A: The code has a compile error because xMethod does not return a value
B: The code has a compile error because xMethod is not declared static
C: The code prints n is 2
D: The code prints n is 3
答案: 【 The code has a compile error because xMethod is not declared static

16、单选题:
All Java applications must have a method ______
选项:
A: public static Main(String[] args)
B: public static Main(String args[])
C: public static void main(String[] args)
D: None of the above
答案: 【 public static void main(String[] args)

17、单选题:
A variable defined inside a method is referred to as _____
选项:
A: a global variable
B: a method variable
C: a block variable
D: a local variable
答案: 【 a local variable

18、单选题:
A method that is associated with an individual object is called ____
选项:
A: a static method
B: a class method
C: an instance method
D: an object method
答案: 【 an instance method

19、单选题:
有以下方法的定义,请选择该方法的返回类型
ReturnType method(byte x, double y) {

return (short)x/y*2;

}
选项:
A: byte
B: short
C: int
D: double
答案: 【 double

20、单选题:
Which of the following statements are correct?
选项:
A: char[][] charArray = {'a', 'b'};
B: char[2][2] charArray = {{'a', 'b'}, {'c', 'd'}};
C: char[2][] charArray = {{'a', 'b'}, {'c', 'd'}};
D: char[][] charArray = {{'a', 'b'}, {'c', 'd'}};
答案: 【 char[][] charArray = {{'a', 'b'}, {'c', 'd'}};

21、单选题:
Suppose a method p has the following heading:
public static int[] p()
What return statement may be used in p()?
选项:
A: return 1;
B: return {1, 2, 3};
C: return int[]{1, 2, 3};
D: return new int[]{1, 2, 3};
答案: 【 return new int[]{1, 2, 3};

22、单选题:
If you declare an array double[] list = {3.4, 2.0, 3.5, 5.5}, the highest index in array list is ________
选项:
A: 0
B: 3
C: 4
D: 5
答案: 【 3

23、单选题:
for-each loop) Analyze the following code:

public class Test {
public static void main(String[] args) {
double[] x = {2.5, 3, 4};
for (double value: x)
System.out.print(value + " ");
}
}
选项:
A: The program displays 2.5, 3, 4
B: The program displays 2.5 3 4
C: The program displays 2.5 3.0 4.0
D: The program displays 2.5, 3.0 4.0
答案: 【 The program displays 2.5 3.0 4.0

24、单选题:
Analyze the following code:

public class Test {
public static void main(String[] args) {
int[] x = {1, 2, 3, 4};
int[] y = x;
x = new int[2];
for (int i = 0; i < y.length; i++)
System.out.print(y[i] + " ");
}
}
选项:
A: The program displays 1 2 3 4
B: The program displays 0 0
C: The program displays 0 0 3 4
D: The program displays 0 0 0 0
答案: 【 The program displays 0 0

25、单选题:
执行完以下代码int [ ] x = new int[25];后,以下哪项说明是正确的( )
选项:
A: x[24]为0
B: x[24]未定义
C: x[25]为0
D: x[0]为空
答案: 【 x[24]为0

26、单选题:
有关类Demo,哪句描述是正确的? ( )
public class Demo extends Base{
private int count;
public Demo(){
System.out.println("A Demo object has been created");
}
protected void addOne() {count++; }
}
选项:
A: 当创建一个Demo类的实例对象时,count的值为0
B: 当创建一个Demo类的实例对象时,count的值是不确定的.
C: 超类对象中可以包含改变count 值的方法。
D: Demo的子类对象可以访问count。
答案: 【 当创建一个Demo类的实例对象时,count的值为0

27、单选题:
以下说法错误的是【 】
选项:
A: Applet小应用程序不可以独立运行
B: 一个JAVA源程序可以没有public修饰的类
C: 在一个JAVA源程序中可以定义多个类
D: 一个java源程序可以有多个public修饰的类
答案: 【 一个java源程序可以有多个public修饰的类

28、单选题:
以下说法不正确的是【 】
选项:
A: private修饰的成员变量可以在本类或其本包中子类中使用
B: java类可以同时实现多个接口,但只能继承一个父类
C: static修饰的成员变量可以不经过实例化直接通过类名引用
D: static不可以和abstract修饰符同时使用
答案: 【 private修饰的成员变量可以在本类或其本包中子类中使用

29、单选题:
以下哪个类能正确编译?【 】
选项:
A: class a{
abstract void disp();
}
B: abstract class a{
void disp(){
System.out.println("welcome to Beijing!");
} }
C: class a{
abstract void disp(){
System.out.println("welcome to Beijing!");
} }
D: abstract class a{
final abstract void disp();
}
答案: 【 abstract class a{
void disp(){
System.out.println("welcome to Beijing!");
} }

30、单选题:
已知在一个类中能正确使用命令:import hr.tech.Wage。以下说法不正确的是【 】
选项:
A: Wage是类名
B: 在Wage类中声明包的命令是package hr.tech
C: hr.tech.Wage是包名
D: 不使用import hr.tech.Wage语句,也可使用new hr.tech.Wage()的方式产生对象
答案: 【 hr.tech.Wage是包名

复习测验2

1、单选题:
要想定义一个不能被实例化的抽象类,在类定义中必须加上修饰符( )。
选项:
A: final
B: public
C: private
D: abstract
答案: 【 abstract

2、单选题:
下述说法中,错误的是
选项:
A: Java中,方法的重载是指多个方法可以共享同一个名字
B: Java中,用abstract修饰的类称为抽象类,它不能实例化
C: Java中,接口不包含方法实现
D: Java中,构造方法可以有返回值
答案: 【 Java中,构造方法可以有返回值

3、单选题:
下面哪个函数不是public void example(){...}的重载函数【 】
选项:
A: public void example( int m){...}
B: public int example(){...}
C: public void example(float f){...}
D: public int example ( int m, float f){...}
答案: 【 public int example(){...}

4、单选题:
下列哪一种叙述是正确的( )
选项:
A: abstract修饰符可修饰字段、方法和类
B: 抽象方法的body部分必须用一对大括号{ }包住
C: 声明抽象方法,大括号可有可无
D: 声明抽象方法不可写出大括号
答案: 【 声明抽象方法不可写出大括号

5、单选题:
下列关于修饰符混用的说法,错误的是( )
选项:
A: abstract不能与final并列修饰同一个类
B: abstract类中不可以有private的成员
C: abstract方法必须在abstract类中
D: static方法中能处理非static的属性
答案: 【 static方法中能处理非static的属性

6、单选题:
为AB类的一个无形式参数无返回值的方法method书写方法头,使得使用类名AB作为前缀就可以调用它,该方法头的形式为( )。
选项:
A: static void method( )
B: public void method( )
C: final void method( )
D: abstract void method( )
答案: 【 static void method( )

7、单选题:
如果类中的成员变量可以被同一包访问,则使用如下哪个约束符【 】
选项:
A: private
B: public
C: protected
D: 缺省约束符
答案: 【 缺省约束符

8、单选题:
类Test1定义如下:
1.public class Test1{
2. public float aMethod(float a,float b){ }
3.
4.}
将以下哪种方法插入行3是不合法的。( )
选项:
A: public float aMethod(float a, float b,float c){ }
B: public float aMethod(float c,float d){ }
C: public int aMethod(int a, int b){ }
D: private float aMethod(int a,int b,int c){ }
答案: 【 public float aMethod(float c,float d){ }

9、单选题:
设已声明了一个类A的两个对象a1,a2,为了初始化 a1和a2,下面语句正确的是
选项:
A: a1,a2=new A();
B: a1=A.new(); a2=A.new();
C: a1=new();a2=new();
D: a1=new A();a2=new A();
答案: 【 a1=new A();a2=new A();

10、单选题:
关于以下说法,描述错误的是【 】
选项:
A: 在JAVA应用程序中main方法里,不能直接使用非静态变量
B: 有abstract修饰的类能够直接实例化
C: 一个非抽象类实现一个接口,在该类中必须重写该接口中所有的方法
D: this和super这两个特殊变量只能用在非静态方法中
答案: 【 有abstract修饰的类能够直接实例化

11、单选题:
若JAVA程序中定义了3个类,编译后可生成(   )个字节码文件。
选项:
A: 4
B: 3
C: 2
D: 1
答案: 【 3

12、单选题:
关于以下程序代码的说明正确的是( )
1. class HasStatic{
2. private static int x=100;
3. public static void main(String args[ ]){
4. HasStatic hs1=new HasStatic( );
5. hs1.x++;
6. HasStatic hs2=new HasStatic( );
7. hs2.x++;
8. hs1=new HasStatic( );
9. hs1.x++;
10. HasStatic.x- -;
11. System.out.println("x="+x);
12. }
13. }
选项:
A: 5行不能通过编译,因为引用了私有静态变量
B: 10行不能通过编译,因为x是私有静态变量
C: 程序通过编译,输出结果为:x=103
D: 程序通过编译,输出结果为:x=102
答案: 【 程序通过编译,输出结果为:x=102

13、单选题:
哪个关键字修饰的变量和方法不能从其他类访问?
选项:
A: protected
B: public
C: private
D: default
答案: 【 private

14、单选题:
关于被私有访问控制符private修饰的成员变量,以下说法正确的是
选项:
A: 可以被三种类所引用:该类自身、与它在同一个包中的其他类、在其他包中的该类的子类
B: 可以被两种类访问和引用:该类本身、该类的所有子类
C: 只能被该类自身所访问和修改
D: 只能被同一个包中的类访问
答案: 【 只能被该类自身所访问和修改

15、单选题:
哪个关键字声明一个常量?
选项:
A: protected
B: static
C: final
D: default
答案: 【 final

16、单选题:
关于被保护访问控制符protected修饰的成员变量,以下说法正确的是
选项:
A: 可以被三种类所引用:该类自身、与它在同一个包中的其他类、在其他包中的该类的子类
B: 可以被两种类访问和引用:该类本身、该类的所有子类
C: 只能被该类自身所访问和修改
D: 只能被同一个包中的类访问
答案: 【 只能被该类自身所访问和修改

17、单选题:
哪个表达式的结果为0.5?
选项:
A: 1 / 2
B: (double) (1 / 2)
C: (double) 1 / 2
D: 1 2
答案: 【 (double) 1 / 2

18、单选题:
给定以下代码
3. public class TestDays {
4. public enum Days { MON, TUE, WED };
5. public static void main(String[] args) {
6. for(Days d : Days.values() )
7. ;
8. Days [] d2 = Days.values();
9. System.out.println(d2[2]);
10. }
11. }
结果正确的是?
选项:
A: TUE
B: WED
C: 输出不可预料
D: 编译错
答案: 【 WED

19、单选题:
不是构造函数特点的是( )
选项:
A: 构造函数与类名相同
B: 构造函数可带参数也可不带
C: 构造函数带有返回类型
D: 构造函数主要完成对类对象的初始工作
答案: 【 构造函数带有返回类型

20、单选题:
给出下面的代码段
public class Base{
int w, x, y ,z;
public Base(int a,int b)
{ x=a; y=b; }
public Base(int a, int b, int c, int d){
________________
w=d; z=c;
} }
在代码说明________处写入如下哪一个代码是正确的?【 】
选项:
A: a=x; b=y;
B: x=a, y=b;
C: super(a,b)
D: this(a,b)
答案: 【 this(a,b)

21、单选题:
编译Java Application 源程序文件将产生相应的字节码文件,这些字节码文件的扩展名为( )。
选项:
A: .java
B: .class
C: .obj
D: .jdk
答案: 【 .class

22、单选题:
不允许作为类及类成员的访问控制符的是( )。
选项:
A: public
B: private
C: static
D: protected
答案: 【 static

23、单选题:
You have a public class called myclass with the main method defined as follows
public static void main(String parm[]){
System.out.println(parm[0]);
}
If you attempt to compile the class and run the program as follows
java myclass hello
What will happen?
选项:
A: Compile time error, main is not correctly defined
B: Run time error, main is not correctly defined
C: Compilation and output of java
D: Compilation and output of hello
答案: 【 Compilation and output of hello

24、单选题:
Which of the following are correct statements to create a Lock so the longest-wait thread will obtain the lock first?()
选项:
A: Lock lock = new Lock();
B: Lock lock = new ReentrantLock();
C: Lock lock = new ReentrantLock(true);
D: Lock lock = new ReentrantLock(false);
答案: 【 Lock lock = new ReentrantLock(true);

25、单选题:
Which specifier essentially declares a variable a global variable?
选项:
A: protected
B: static
C: final
D: default
答案: 【 static

26、单选题:
如何在Condition对象实例上创建线程锁?()
选项:
A: Condition condition = lock.getCondition();
B: Condition condition = lock.newCondition();
C: Condition condition = Lock.newCondition();
D: Condition condition = Lock.getCondition();
答案: 【 Condition condition = lock.newCondition();

27、单选题:
Which of the following statement prints smithexam1test.txt?
选项:
A: System.out.println("smithexam1test.txt");
B: System.out.println("smith\exam1\test.txt");
C: System.out.println("smith"exam1"test.txt");
D: System.out.println("smith"exam1"test.txt");
答案: 【 System.out.println("smith\exam1\test.txt");

28、单选题:
有如下代码:
Class a extends Thread{
Public void run{
For(int i=1;i<100;i++){System.out.println(i);}
}}
能正确启动a中run方法的是()
选项:
A: a.run();
B: a a1=new a();
a1.run();
C: a a1=new a();
a1.start();
D: a a1=new a();
Thread t=new Thread(a);
a.start();
答案: 【 a a1=new a();
a1.start();

29、单选题:
Which of the following is the correct expression of character 4?
选项:
A: 4
B: "4"
C: '4'
D: '004'
答案: 【 '4'

30、单选题:
程序如下:
public class Borley extends Thread
{
public static void main(String[] argv)
{
Borley b = new Borley();
b.start();
}
public void run()
{
System.out.println("Running");
}
}
下面描述正确的是()。
选项:
A: 通过编译和运行但是没有任何输出
B: 通过编译,运行后输出"Running"
C: 编译出错,没有线程可供运行
D: 编译出错,没有权限使用Thread
答案: 【 通过编译,运行后输出"Running"

复习测验3

1、单选题:
Which of the following statements are true?()
选项:
A: The wait(), notify(), and notifyAll() methods must be invoked from a synchronized method or a synchronized block.
B:

剩余75%内容付费后可查看

发表评论

电子邮件地址不会被公开。 必填项已用*标注