搜题

对下列程序的叙述中,正确的是(  )。 1:public class X extends Thread implements Runnable{2:public void run(){3:system.out.println(this is run()); 4:}5:public static void main(String args[]){6:Thread t=new Thread(n

计算机二级 2023-04-24

[单选] 对下列程序的叙述中,正确的是(  )。
1:public class X extends Thread implements Runnable{
2:public void run(){
3:system.out.println("this is run()");
4:}
5:public static void main(String args[]){
6:Thread t=new Thread(new X()):
7:t.start();
8:}
9:}

A . 第1行会产生编译错误
B . 第6行会产生编译错程
C . 第6行会产生运行错误
D . 程序正常运行



参考答案:D

参考解析:

D。【解析】程序正常运行打印this is run()。用Thread类的构造方法Thread(Runnable target)创建线程对象时,构造方法中的参数必须是一个具体的对象,该对象称作线程的目标对象,创建的目标对象的类必须实现Runnable接口。

下面程序的运行结果为( )。 #include<iostream.h>void main(){for(int a=0,x=0;!x&&a<=10;a++){a++: }cout<<a<<endl: }

类别: 考级 | 计算机二级 2023-04-24

下列选项,不正确的是( )。

类别: 考级 | 计算机二级 2023-04-24

下面对静态数据成员的描述中,正确的是( )。

类别: 考级 | 计算机二级 2023-04-24

下列关于多态性的描述,错误的是( )。

类别: 考级 | 计算机二级 2023-04-24

对于类定义 class A{public: void func2(){} }; class B:public A{ public: w)id funcl()| cout<<class B func l”<<endl:}virtual voiIl fi

类别: 考级 | 计算机二级 2023-04-24

下列语句中错误的是( )。

类别: 考级 | 计算机二级 2023-04-24

下面是一个模板声明的开始部分: template<typename T>double…由此可知( )。

类别: 考级 | 计算机二级 2023-04-24

有以下语句,则对a数组元素的引用不正确的是(0≤i≤9)( )。 int a[10]={0,1,2,3,4,5,6,7,8,9},*P=a;

类别: 考级 | 计算机二级 2023-04-24

有以下程序: #include<iostream.h> float tun(int X,int Y) {return(X+Y);} void main(){int a=2,b=5,c=8; cout<<fun((int)fun(a+c,B.,a—C.; 程序运行后的输出结果是( )。

类别: 考级 | 计算机二级 2023-04-24

下列程序的输出结果为( )。 #include<iostream.h) int fune(int n){if(n<1)return l; else return n+time(n一1); return 0; }void main() {cout<<func(5)<<endl; }

类别: 考级 | 计算机二级 2023-04-24

加载更多~