更多“20、填空,完成程序。 static void Main(s…”相关的问题
第1题
class SubThread extends Thread{ public void run(){ for (int i=1; i<=20; i++) system.out.print("次" + i ", "); } public testextendsthread{ static void main(string[] args){ subthread sub="new" subthread(); sub.start(); for (int system.out.print("主" 线程sub获得cpu使用权时,会执行sunthread类中的run()方法。(>
点击查看答案
第2题
阅读下面程序: public class ThreadTest { public static void main(String args[]) throws Exception { int i=0; Hello t=new Hello(); ______; While(true) } System.out.println("Good Morning"+i++); if(i==2&&t.isAlive()) { System.out.println("Main waiting for Hello!"); t.join(); //等待t运行结束 } If(i==5)break:} } } class Hello extends Thread } int i; public void run() while(true) { System.out.println("Hello"+i++): If(i==5)break; } } } 为使该程序正确执行,下画线处的语句应是
A.t.sleep()
B.t.yield()
C.t.interrupt()
D.t.start()
点击查看答案
第3题
【单选题】(9-3)执行以下程序的输出结果是( )。 public class Demo { public static void main(String[] args) { try { return; } finally { System.out.println("1"); } } }
A、编译失败
B、运行时抛出异常
C、1
D、程序能够正常运行但没有任何输出
点击查看答案
第4题
用语言描述下面的程序:namespace StringTest{ class Program { static void Main(string[] args) { int nResult = 0; bool bResult = false; string str = "hello everyOne!!"; bResult = str.Contains("e"); Console.WriteLine("Contains(\"e\") = " + bResult); nResult = str.IndexOf("e"); Console.WriteLine("IndexOf(\"e\") = " + nResult); nResult = str.LastIndexOf("e"); Console.WriteLine("LastIndexOf(\"e\") = " + nResult); } } }
点击查看答案
第5题
请阅读下面的程序 class WhileDemo4 { public static void main(String[] args) { int n = 5; while (n > 10) { System.out.print(n); n++; } } } 下列选项中,哪一个是程序运行的结果
A、无输出
B、输出56789
C、死循环
D、编译错误
点击查看答案
第6题
写出下面程序的运行结果,了解while语句的使用。public class Useli3 { public static void main(String args[ ]){ int n = 9; while(n>6){ n--; System.out.print(n); } } }
点击查看答案
第7题
22、填空,完成程序。 static void Main(string[] args)方法中的代码为: int[] arr = { 50,2,3,4,5 };//定义一个一维数组,并为其赋值 foreach (___________ n in arr) //使用foreach语句循环遍历一维数组中的元素 { Console.Write("{0}", n+"\t"); }
点击查看答案
第8题
23、阅读程序,请写出结果。 int x=10; int y=15; int result; result=x & y; Console.WriteLine(result); result的值是:_______________.
点击查看答案
第9题
3、用do…while语句找到1到1000之间的合数,以每行10个的方式输出。
点击查看答案
第10题
24、阅读程序,请写出结果。 bool b1=false; int num=50; bool b2; b2=b1&(num>30?true:false); Console.WriteLine(b2); b2的值是:_______________。
点击查看答案