PublicclassHoltextendsThread{PrivateStringsThreadName;Publicstaticvoidmain(Stringargv[]){Holth=newHolt();h.go();Holt(){};Holt(Strings){sThreadName=s;PublicStringgetThreadName(){returnsThreadName;}}Publicvoidgo(){Hotfirst=newHot("first");first.start();Hots

题目

PublicclassHoltextendsThread{PrivateStringsThreadName;Publicstaticvoidmain(Stringargv[]){Holth=newHolt();h.go();Holt(){};Holt(Strings){sThreadName=s;PublicStringgetThreadName(){returnsThreadName;}}Publicvoidgo(){Hotfirst=newHot("first");first.start();Hotsecond=newHot("second");second.start();}Publicvoidstart(){For(inti=0;i<2;i++){System.out.print(getThreadName()+i);Try{Thread.sleep(100);}catch(Exceptione){System.out.print(e.getMessage());}}}}当编译运行上面代码时,将会出现()

A.编译时错误

B.输出first0,second0,first0,second1

C.输出first0,first1,second10,second1

D.运行时错误


相似考题
更多“PublicclassHoltextendsThread{PrivateStringsThreadName;Publicstaticvoidmain(Stringargv[]){H ”相关问题
  • 第1题:

    以下程序的运行结果为:public class Test{public static void main(String argv[ ]){System.out.println("x="+ 5、;}}

    A. 5

    B. x=5

    C. "x="+5

    D. "x="5


    正确答案:B

  • 第2题:

    以下哪个是Java应用程序入口的main方法头?

    A.public static int main(char args[])

    B.public static void main(String a[])

    C.public static void MAIN(String args[])

    D.public static void main(String argv)


    public static void main(String[] args);

  • 第3题:

    执行下面程序段的输出结果为()。 public class Q { public static void main(String argv[]) { int anar[]=new int[5]; System.out.println(anar[0]); } }

    A.0

    B.1

    C.2

    D.5


    20 21

  • 第4题:

    执行下面的程序段,输出结果为______。

    publicclassQ

    {

    publicstaticvoidmain(Stringargv[])

    {

    intanar[]=newint[5];

    System.out.println(anar[0]);

    }

    }


    正确答案:×
    0 解析: 本题考查Java中数组的定义和初始化。在该方法里定义并动态初始化了一个整型数组anar,由于没有赋初值,系统给默认的初始值是数组中的每个元素全部为零。所以输出数组中的第一个元素anar[O]时,自然也是等于零。

  • 第5题:

    17、以下程序的运行结果为? public class Test5{ public static void main(String argv[]){ StringBuffer x = new StringBuffer("你好"); myMethod(x); System.out.print("x=" + x); } public static void myMethod(StringBuffer s){ s.append(",Hi"); } }


    B