单项选择题
下面程序段的输出结果是
public class Test
public static void main(String args[])
int n=5,sum=O;
while(n>0)
sum+=n;
--n;
System.out.println("sum is "+Sum);
A.sum is 14
B.sum is 15
C.sum is 10
D.sum is 5
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
下面的程序是完成一个容器的例子,所缺部分正确的选项是( )。 import java.awt.*; public class MyFrame extends Frame public static void main(String args[]) MyFrame fr=new MyFrame( Hello Out There! ); fr.setSize(200,200); fr.setBackground(Color.red); ______; public MyFrame(String str) super(str); 调用父类的构造方法
A.fr.setVisible(false)
B.fr.setVisible
C.fr.setVisible(true)
D.以上都不是
点击查看答案&解析
单项选择题
下列程序的功能是在监控台上每隔一秒钟显示一个字符串“你好!”,能够填写在程序中画线位置,使程序完整并能正确运行的语句是 public class Exam implements Runnable public static void main(String args[]) Exam t=new Exam(); Thread tt=new Thread(t); tt.start(); public void run() for(;;) try ; catch(e) System.out.println( 你好! );
A.sleep(1)
RuntimeException
B.sleep(1000)
InterruptedException
C.Thread.sleep(1)
InterruptedException
D.Thread.sleep(1000)
InterruptedException
点击查看答案&解析
相关试题
有下面的Applet程序段: import.java.aw...
创建一个10行40列的文本区域tal的正确...
给相同优先级线程一个执行的机会调用___...
下面的程序用“冒泡”法将数组a中的10个...
通过类MyClass中的不含参数的构造函数,生...