更多"下面程序段的输出结果是 classTest{ public st"的相关试题:
[单项选择]下面程序段的输出结果是 class Test{ public static void main(String args[]){ MyThread t=new MyThread( ); t.displayOutput("t has been createD) "; t.start( ); } } class MyThread extends Thread{ public void displayOutput(String s){ System.out.println(s); } public void nm( ){ displayOutput("t is running. "); }
A. t has been create t is runnin
B. t has been create
C. t is runnin
D. 编译出错
[单项选择]下面程序段的输出结果是
public class Test
public static void main(String args[])
int n=5,sum=0;
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
[单项选择]阅读下面代码 public class { public static void main(String[] args) { double d=12.3; Decrementer dec=new Decrementer( ); dec.decrement(d); System.out.println(d); } } class Decrementer { public void decrement(double decMe) { decMe=decMe-1.0; } } 代码执行后输出的结果是
A. 12.3
B. 11.3
C. 13.3
D. -1.0
[单项选择]给出下面代码
public class Test1
pubic static void main (String args[])
int m;
switch (m)
case 0:System.out.printIn( "case 0");
case 1:System.out.printIn("case 1")j break;
case2:
de fault: System.out.printIn("default");
下列m的哪个值将引起“default”的输出______。
A. 0
B. 1
C. 2
D. 3
[单项选择]下面程序段的输出结果是( )。
class Test
public static void main(String args[])
MyThread t=new MyThread( );
t.displayOutput("t has been createD");
t.start( );
Class MyThread extends Thread
public void displayOutput(String s)
System.out.println(s);
public void run( )
displayOutput("t is running.");
A. t has been created.
B. t has been created.
C. t is running.
D. 编译出错
[填空题]public class Test
public static void main(String[ ] args)
String name[ ]=new String[5];
for(int i=0; i<args. length; ++i) name[i] = args[i];
System. out. println(name[2]);
命令行中的输入为:java Test a b
程序的输出是 【11】 。
[单项选择]下面程序段的输出结果是______。
class Test
public static void main (String args[])
MyThread t=new MyThread( );
t. displayOutput("t has been createD");
t. start( );
Class MyThread extends Thread
public void displayOutput(String s)
System. out. println(s):
)
public void run( )
displayOutput("t is running.");
A. t has been created.
B. t has been created.
C. t is running.
D. 编译出错
[简答题]下面的程序是从命令行输入3个数传递到public static void main(String args[])方法中(如java Is Triangle 34 5),并判断这3个数能否构成三角形的3条边,并显示相应的结果。请在程序的每条横线处填写一个位运算符,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
源程序文件代码清单如下:
public class IsTriangle
public static void main(String args[ ])
int a[ ]=new ______[args.length];
for(int i=0;i<args.length;i++)
a[i]= ______;
if(______)
System.out.println(a[0]+ ","+a[1]+ ",
"+a[2]"能构成三角形的3条边").
else
System.out.println(a[0]+ ","+a[1]+ ",
"+a [2] "不能构成三角形的3条边");
[填空题]public class Sum
public static void main(String [] args)
int j=10;
System.out.println("j is : "+j);
calculate(j);
System.out.println("At last, j is : "+j);
static void calculate (int j)
for (int i = 0;i<10;i++)
j++;
System.out.println("j in calculate( ) is: "+j);
输出结果为:
j is : (1)
j in calculate( ) is : (2)
At last j is : (3)
[简答题]【说明】
下面的程序是从命令行输入3个数传递到public static void main(String args[])方法中 (如java IsTriangle 3 4 5),并判断这3个数能否构成三角形的3条边,并显示相应的结果。请在程序的每条横线处填入适当的语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
public class IsTriangle{
public static void main( String args[ ]){
int a[] =new (1) [args. (2) ];
for(int i=0;i<3; (3) )
{
a[i]= (4)
}
if( (5) )
System. out. println(a[0] +","+a[1] +","+a[2]"能构成三角形的3条边");
else
System. out. println(a[0] +","+a[1] +","+a[2]"不能构成三角形的3条边);
}
}
[单项选择]下面程序段的运行结果是
void main ( )
int t, a, b, C;
a=1;b=2;C=2;
while(a<b<c)
t=a;a=b;b=t;c--;
cout < < a < < "," < < b < < "," < < C;
A) 1,2,0 B) 2,1,0 C) 1,2,1 D) 2,1,1
[填空题]下列程序段的输出结果是 [7] 。
#include<iostream.h>
void main( )
int i=10,sum=0;
do
sum=+sum+i;
i=i-2;
while(i>=2);
cout<<sum<<end1;
[单项选择]下列程序段运行的结果为
public class Test
static void print(String s,int i)
System.out.println("String:"+s+",int:"+i);
static void print(int i, String s)
System.out.println("int:"+i+",String:"+s);
public static void main(String [] args)
print(99,"Int first");
A. String:Stringfirst,int:11
B. int:11,String:Int first
C. String:String first,int:99
D. int:99,String:int first
[单项选择]下面程序的输出结果是
public class Test
public static void main(String[] args)
int[]array=2,4,6,8,10;
int size=6;
int result=-1:
try
for(int i=0;i<size&&result==-1;i++)
if(array[i]==20)result=i;
catch(ArithmeticException e)
System.out.println("Catch---1");
catch(ArrayIndexOutOfBoundsException e)
System.out.println("Catch---2");
catch(Exception e)
System.out.println("Catch---3");
A. Catch---1
B. Catch一--2
C. Catch---3
D. 以下都不对