题库 题库

【单选题】

在多线程并发程序设计中,能够给对象x加锁的语句是
  • A.x.wait( )

  • B.synchronized(x)

  • C.x.notify( )

  • D.x.synchronized( )

参考答案

查看答案

相关试题

单选题 下列数据结构中,能够按照“先进后出”原则存取数据的是 查看答案
单选题 对于循环队列,下列叙述中正确的是 查看答案
单选题 Java中的基本数据类型int在不同的操作系统平台的字长是 查看答案
单选题 在下列程序的空白处,应填入的正确选项是
Import java.io.*;
Pulilc class ObjectStreamTest{
Publilc static void main(string args[]) throws IOException{
ObjectOutputStream oos= new ObjectOutputStream
(new FileOutputStream(“serial.bin”));
Java.util.Date d= new Java.util.Date();
Oos        (d);
ObjectInputStream ois=
new ObjectInputStream(new FileOutputStream(“serial.bin”));
try{
java.util.date restoredDate =
(Java.util.Date) ois.readObject();
System.out.println
(“read object back from serial.bin file:”
+ restoredDate);
}
Catch (ClassNotFoundException  cnf) {
System.out.println (“class not found”);
}
查看答案
单选题 算法的空间复杂度是指 查看答案
单选题 阅读下列程序片段
Public void test(){
Try{
sayHello();
system.out.println(“hello”);
} catch (ArrayIndexOutOfBoundException e) {
System.out.println(“ArrayIndexOutOfBoundException”);
}catch(Exception e){
System.out.println(“Exception”);
}finally {
System.out.println(“finally”);
}
}
如果sayHello( )方法正常运行,则test( )方法的运行结果将是
查看答案
单选题 下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是
public class FindKeyWords{
public static void main(sring[] args){
sting text=
“ An array is a data structur that stores a collection of”
+ “values of the same type . You access each individual value”
+ “through an integer index . For example,if a is an array”
+ “of inergers, then a[i] is the ith integer in the array.”;
Int arrayCount =0;
Int idex = -1;
Sting arrarStr =”array”;
Index = text.indexof(arrayStr);
While(index          0) {
++arrayCount;
Index += arrayStr.length();
Index = text.indexof(arrayStr,index);
}
System.out.println
(“the text contains” + arrayCount + “arrays”);
}
}
查看答案
单选题 下列表达式中,类型可以作为int型的是 查看答案
单选题 Class类的对象由______自动生成,隐藏在.class文件中,它在运行时为用户提供信息。 查看答案
单选题 用于设置组件大小的方法是 查看答案
单选题 软件详细设计产生的图如下:
  
该图是
查看答案
单选题 下列运算符中,优先级最高的是 查看答案
单选题 下列数据结构中,属于非线性结构的是 查看答案
单选题 如果线程正处于运行状态,则它可能到达的下一个状态是 查看答案
单选题 在下列程序的空白处,应填入的正确选项是
import java.io.*;
Public class writeInt{
Public static void main(string[ ] a) {
Int[ ] myArray = {10,20,30,40};
try{
DataOutputSystem dos= new DataOutputSystem
(new FileOutputSystem(“ints.dat”));
for  (int i=0;I<myArray.length;i++)
dos。writeInt(myArray[i]);
dos.
System.out.println
(“Have written binary file ints.dat”);
}
Catch(IOException ioe)
{    System.out.println(“IO Exception”);
}
}
}
查看答案
单选题 在关闭浏览器时调用,能够彻底终止Applet并释放该Applet所有资源的方法是 查看答案
单选题 下列变量名的定义中,符合Java命名约定的是 查看答案
单选题 阅读下列程序
Public class Test implements Runnable{
Private int x=0;
Private int y=o;
boolean flag=true;
Public static void main(string[ ] args) {
Test  r =new Test( );
Thead t1=new Thead(r);
Thead t2=new Thead(r);
t1.start( );
t2.start( );
}
Public void run(){
While(flag) {
x++;
y++;
system.out.println(“(” +x_ “,”+y+”)”);
if (x>=10)
flag=false;
}
}
}
下列对程序运行结果描述的选项中,正确的是
查看答案
单选题 为了将HelloApplet(主类名为HelloApplet.class)嵌入在greeting.html文件中,应该在下列greeting.html文件的横线处填入的代码是
<HTML>
<HEAD>
<TITLE> Greetings </TITLE>
</HEAD>
<BODY>
<APPLET ______>
</APPLET>
</BODY>
</HTML>
查看答案
单选题 软件设计中划分模块的一个准则是 查看答案