C 8. class A implements Runnable{
int i;
public void run(){
try{
Thread.sleep(5000); i=10;
}catch(InterruptException e){}
}
public static void main(String[] args)
{
try{
a=new A();
Thread t=new Thread(a);
t.start();
14)
int j=i;
16)
}catch(Exception e){}
}
}
在第 14 行加上哪些代码才能保证在第 16 行时 j=10? (单选)
A.wait();
B.t.wait();
C.t.join();
D.t.yield();
ify();
A 2. 考察以下陈述:
陈述 A:属性定义类的特征。
共工是什么神陈述 B:行为定义类所执行的动作。
什么什么而起
关于这些陈述,以下中哪个是正确的?
A 两个陈述都为真。好听的网名古风
B 两个陈述都为假。
C 陈述 A 为真,陈述 B 为假。
D 陈述 A为假,陈述 B 为真。 (单选) (答题时限:00:00:30)
D 3. 11. for (int i =0; i <3; i++) {
12. switch(i) {
13. ca 0: break;
14. ca 1: System.out.print(“one “);
15. ca 2: System.out.print(“two “);
16. ca 3: System.out.print(“three “);
17. }
18. }
19. System.out.println(“done”);
What is the result? (单选)
A.done
B.one two done
C.one two three done
D.one two three two three done
E.Compilation fails.
A 4. 11. public void test(int x) {
12. int odd = x%2;
13. if (odd) {
14. System.out.println(“odd);
15. } el {
16. System.out.println(“even”);
哑铃健身动作
17. }
18. }
Which statement is true? (单选)
A.Compilation fails.
B.“odd” will always be output.
C.“even” will always be output.
D.“odd” will be output for odd values of x, and “even” for even values.
E.“even” will be output for add values of x, and “odd” for even values.
A 5. 为把文件指针设置为文件内的特定位置,你将使用以下RandomAccessFile 类方法中哪个?
(单选) (答题时限:00:00:30)
A.void ek(long pos)
B.long getFilePointer()
C.long length()
D.Byte [] readBytes(long)
B 6. You want to limit access to a method of a public class to members of the same class. Which access accomplishes this objective? (单选)
A.public
B.private
C.protected
D.transient
E.default access
D 7. Math类所在的包位置为( )。 (单选)
A.java.awt.*;
B.java.io.*
C.java.sql.*;
D.java.lang.*
小学班会课教案
B 8. 1. public class Test {
2. private static float[] f = new float[2];
3. public static void main(String args[]) {
4. System.out.println(“f[0] = “ + f[0]);
5. }
8. 1. public class Test {
2. private static float[] f = new float[2];
3. public static void main(String args[]) {
4. System.out.println(“f[0] = “ + f[0]);
5. }
6. }
What is the result? (单选)
A.f[0] = 0
基础工程施工 B.f[0] = 0.0
C.Compilation fails.
D.An exception is thrown at runtime.
C 1. 执行完下面的程序段后,k的值为( )。
int k=0;
label:for(int i=1;i<3;i++)
{
for(int j=1;j<3;j++)
{
k+=i+j;
System.out.println(k);
if(i==2) continue label;
}
} (单选)
A.3
B.5
简笔画烟花 C.8
D.12
2. 1. public interface Foo {
2. int k = 4;
3. }
Which three are equivalent to line 2? (Choo three) (多选)
A.final int k = 4;
B.public int k = 4;
C.static int k = 4;
D.abstract int k = 4;
E.volatile int k = 4;
F.protected int k = 4;
★标准答案:A,B,C
答题结果:正确!
答题结果:错误!
A,B 3. 下面关于线程的说法正确的是( )。 (多选)
A.Java支持多线程机制
B.一个线程创建并启动后,它将执行自己的run()方法,如果通过派生Thread类实现多线程,则需要在子类中重新定义run()方法,把需要执行的代码写入run()方法中;如果通过实现Runnable接口实现多线程,则需要编写接口中的抽象方法——run()方法的方法体。
C.要在程序中实现多线程,必须导入Thread类:import java.lang.Thread;
D.一个程序中的主类不是Thread的子类,该类也没有实现Runnable接口,则这个主类运行不能控制主线程的休眠。
A 4. import java.io.IOException;
public class ExceptionTest
{
public static void main(String args[])
{
try
{
methodA();
}
catch(IOException e)
{ System.out.println("Caught Exception"); }
}
public void methodA()
{
throw new IOException();
}
}
结果是( )? (单选)
A.代码不能编译。
B.输出是"Caught Exception"
C.输出是 Caught IOException
D.程序正常执行,但没有打印信息。
马冲什么生肖
D 5. 11. int i =1,j =10;