1、关于以下application的说明,正确的是( )
1. class StaticStuff
2. {
3. static int x=10;
4. static { x+=5;}
5. public static void main(String args[ ])
6. {
7. System.out.println(“x=” + x);
8. }
9. static { x/=3;}
10. }
A、 4行与9行不能通过编译,因为缺少方法名和返回类型
B、 9行不能通过编译,因为只能有一个静态初始化器
C、 编译通过,执行结果为:x=5
D、 编译通过,执行结果为:x=32、以下代码完成画线功能,指出所画线的颜色( )
1.g.setColor(Color.red.green.yello.cyan);
2.g.drawLine(0,0,100,100);
A、red B、green C、yello D、cyan3、类Teacher和Student是类Person的子类;
Person p;
Teacher t;
Student s;
//p, t and s are all non-null.
if(t instanceof Person) { s = (Student)t; }
最后一句语句的结果是:
A 、将构造一个Student对象;
B 、表达式是合法的;
C 、表达式是错误的;
D 、编译时正确,但运行时错误。
3.运行下列程序, 会产生什么结果
public class X extends Thread implements Runable{
public void run(){
System.out.println("this is run()");
}
public static void main(String args[])
{
Thread t=new Thread(new X());
t.start();
}
}
A 、第一行会产生编译错误
B 、第六行会产生编译错误
C 、第六行会产生运行错误
D 、程序会运行和启动
1. class StaticStuff
2. {
3. static int x=10;
4. static { x+=5;}
5. public static void main(String args[ ])
6. {
7. System.out.println(“x=” + x);
8. }
9. static { x/=3;}
10. }
A、 4行与9行不能通过编译,因为缺少方法名和返回类型
B、 9行不能通过编译,因为只能有一个静态初始化器
C、 编译通过,执行结果为:x=5
D、 编译通过,执行结果为:x=32、以下代码完成画线功能,指出所画线的颜色( )
1.g.setColor(Color.red.green.yello.cyan);
2.g.drawLine(0,0,100,100);
A、red B、green C、yello D、cyan3、类Teacher和Student是类Person的子类;
Person p;
Teacher t;
Student s;
//p, t and s are all non-null.
if(t instanceof Person) { s = (Student)t; }
最后一句语句的结果是:
A 、将构造一个Student对象;
B 、表达式是合法的;
C 、表达式是错误的;
D 、编译时正确,但运行时错误。
3.运行下列程序, 会产生什么结果
public class X extends Thread implements Runable{
public void run(){
System.out.println("this is run()");
}
public static void main(String args[])
{
Thread t=new Thread(new X());
t.start();
}
}
A 、第一行会产生编译错误
B 、第六行会产生编译错误
C 、第六行会产生运行错误
D 、程序会运行和启动
二、不知
三、D
四、D
Runable?