下列程序的运行结果是______。 class A implements Runnable { int a; iht i = 2; A(int x) { a = x; } public void run() { while(i > 0) { System.out.println("线程" + a); i--; } } } public class Testl3 { public static void main(String[] args) { Thread a1 = new Thread(new A(1

题目

下列程序的运行结果是______。 class A implements Runnable { int a; iht i = 2; A(int x) { a = x; } public void run() { while(i > 0) { System.out.println("线程" + a); i--; } } } public class Testl3 { public static void main(String[] args) { Thread a1 = new Thread(new A(1)); Thread a2 = new Thread(new A(2)); a1.start(); a2.start(); } }

A.线程1 线程1 线程2 线程2

B.线程1 线程2

C.线程1 线程2 线程1 线程2

D.线程1 线程1 线程1 线程1


相似考题
更多“下列程序的运行结果是______。class A implements Runnable{int a;iht i = 2;A(int x){a = x;}pub ”相关问题
  • 第1题:

    有以下程序 int fa(int x) {return x*x;} int fb(int x) {return x*x*x;} int f(int(*f1)(),int(*f2)(),int x) { return f2(x)-f1(x);} main() {int i; i=f(fa,fb,2);pfintf(“%d\n”,i); } 程序运行后的输出结果是

    A.-4

    B.1

    C.4

    D.8


    正确答案:C
    解析:函数f()有3个形式参数f1、f2和x,其中f1、f2是指向函数的指针变量。在main()函数中执行了函数调用“f(fa,fb,2)”,从而使f()的形式参数f1指向了fa,形式参数f2指向了fb,把实参2传给了形参变量x。函数f()中的return语句相当于“fb (2)-fa(2)”(fb(2)的返回值为2*2*2=8,fa(2)返回值为2*2=4)即(8-4),值为4。函数f()执行后把返回值4赋给了i,输出i的值是4。

  • 第2题:

    有以下程序: int fa(int x) { return x*x; } int fb(int x) { return x*x*x; } int f(int (*f1)(),int (* f2)(),int x) { return (*f2)(x)-(*f1)(x); } main() { int i; i=f(fa,fb,2); printf("%d\n",i); } 程序运行后的输出结果是( )

    A.-4

    B.1

    C.4

    D.8


    正确答案:C

  • 第3题:

    00330038003000301585067361821下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

    A.<class 'int'> <class 'float'> <class 'str'>

    B.<class 'float'> <class 'int'> <class 'str'>

    C.<class 'str'> <class 'float'> <class 'int'>

    D.<class 'str'> <class 'int'> <class 'float'>


    A

  • 第4题:

    有以下程序: int fa(int x) { return x*x;) int fb(int x) { return x*x*x;} int f(int (*f1)().int (*f2)(),int x) { return f2(x)-f1(x); } main() { int i; i=f(fa,fb,2);printf("%d\n",i); } 程序运行后的输出结果是( )。

    A.-4

    B.1

    C.4

    D.8


    正确答案:C
    解析:函数f()有3个形式参数f1、f2和x,其中f1、f2是指向函数的指针变量。在main()函数中执行了函数调用“f(fa,fb,2)”,从而使f()的形式参数f1指向了fa,形式参数f2指向了fb,把实参2传给了形参变量x。函数f()中的return语句相当于“fb(2)-fa(2)” (fb(2)的返叫值为2*2*2=8,fa(2)返回值为2*2=4)即(8-4),值为4。函数f()执行后把返回值4赋给了i,输出i的值是4。所以4个选项中C正确。

  • 第5题:

    下列程序运行后的输出结果是()。 include void fun(int,int,int*); void main() { i

    下列程序运行后的输出结果是( )。 #include<iostream.h> void fun(int,int,int*); void main() { int x,y,z; fun(5,6,&x); fun(7,x,&y); fun(x,y,&z); cout<<x<<","<<y<<","<<z<<end1; } void fun(int a,int b,int *c) { b+=a; *c=b-a; }

    A.5, 5, 5

    B.6, 6, 6

    C.5, 6, 7

    D.7, 7, 7


    正确答案:B
    解析:由程序中的main函数入手,分别调用fun函数,第一个调用中x参数为引用地址,调用后x的值为6,因为参数为地址,所以第二个调用中的x参数值为6,调用后y的计算结果为6。同理, z在第三个函数调用后z的值为6。

  • 第6题:

    下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

    A.<class 'int'> <class 'float'> <class 'str'>

    B.<class 'float'> <class 'int'> <class 'str'>

    C.<class 'str'> <class 'float'> <class 'int'>

    D.<class 'str'> <class 'int'> <class 'float'>


    C.循环执行1次