更多"阅读下面程序 public class Test implement"的相关试题:
[单项选择]阅读下面程序
public class Test implements Runnable
private int x=0;
private int y=0;
boolean flag=true;
public static void main(String[]args)
Test r=new Test( );
Thread t1=new Thread(r);
Thread t2=new Thread(r);
t1.start( );
t2.start( );
public void run( )
while(flag)
x++;y++;
System.out.println("("+x+","+y+")");
if(x >=10) flag=false;
下列对程序运行结果描述的选项中,正确的是
A. 每行的(x,y)中,可能有x≠Y;每一对(x,y)值都出现两次
B. 每行的(x,y)中,可能有x≠y;每一对(x,y)值仅出现一次
C. 每行的(x,y)中,x=y;每一对(x,y)值都出现两次
D. 每行的(x,y)中,x=y;每一对(x,y)值都出现一次
[单项选择]阅读下列程序:
Public class Test implements Runnable
Private int x=0;
Private int y=o;
boolean flag=true;
Public static void main(string[]args)
Test r=new Test( );
Thead t1=new Thead(r);
Thead t2=new Thead(r);
t1. start( );
t2. start( );
Public void run( )
While(flag)
x++;
y++;
system. out. println("("+x_", "+y+")");
if(x>=10)
flag=false;
下列对程序运行结果描述的选项中,正确的是______。
A. 每行的(x,y)中,可能有x≠y;每一对(x,y)值都出现两次
B. 每行的(x,y)中,可能有x≠y;每一对(x,y)值仅出现一次
C. 每行的(x,y)中,可能有x=y;每一对(x,y)值都出现两次
D. 每行的(x,y)中,可能有x=y;每一对(x,y)值都出现一次
[填空题]请阅读下面程序
public class Test
public static void main (String[] args)
int i,j;
for (i=1;i<5;i++)
for (j=1;j<=i;j++)
system.out.print (i+"X"+j+"="+i*j+" ");
System.out.println( );
程序执行完后,i循环和j循环执行的次数分别是 【12】 。
[单项选择]阅读下面程序
public class Test4
public static void main (String args[])
int i=10, j=3;
float m=213.5f,n=4.0f
System.out.printIn (i%j);
System.out.printIn (m%n);
程序运行的结果是______。
A. 1.0和1.5
B. 1和1.5
C. 1.0和2.5
D. 1和2.5
[单项选择]阅读下面程序
public class Test1
public static void main(String[] args)
System.out.println(34+56-6);
System.out.println(26*2-3);
System.out.println(3*4/2);
System.out.println(5/2);
程序运行的结果是
A. 84
B. 90
C. 84
D. 68
[单项选择]阅读下面程序
public class Test2 ______
public static void main(String[] args)
Thread t=new Test2( );
t.start( );
public void run( )
System.out.println("How are you.");
程序中下画线处应填入的正确选项是
A. implements Thread
B. extends Runnable
C. implements Runnable
D. extends Thread
[单项选择]下面程序的输出结果是
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. 以下都不对
[单项选择]下面程序段的输出结果是
public class Test
public static void main(Stringargs[])
int x,y;
x=(int)Math.sqrt(5)/2+(int)Math.random( )*5/2;
y=(int)Math.sqrt(3)/2+(ht)Math.random( )*3/2;
if(x>y)
System.out.println(”x>y”);
else if(x=y)
System.out.println(”x=y”);
else
System.out.Println(”x<y”);
A. x>y
B. x=y
C. x<y
D. 编译错误
[单项选择]下面程序段的输出结果为
public class Test
public static void main(String args[])
boolean a,b,c;
a=(3<5);
b=(a==true);
System.out.printin( "a="+a+"b="+b) ;
c-(b==false);
System.out.println(b="+b+"e="+c) ;
A. a=true b=false
B. a=true b=false
C. a=true b=true
D. a=false b=false
[填空题]阅读下面代码
public class Test2
public static void main(String args[])
System.out.println(5/2);
其执行结果是______。
[填空题]阅读下面代码
public class Test2 {
public static void main(String args[]) {
System.out.println(5/2);}
}
其执行结果是______。
[单项选择]阅读下面代码 public class Test2005 { public static void main(String args[]) { String s="Test"; switch(s) { case"Java":System.out.print("Java"); break; case"Language":System.out.print("Language"): break; case"Test":System.out.print("Test"); break; } } } 其运行结果是
A. Java
B. Language
C. Test
D. 编译出错
[单项选择]下面程序段的输出结果为
public class Test
public static void main(String args[])
boolean a,b,c;
a=(3<5);
b=(a==true);
System.out.println("a="+a+"b="+b);
c=(b==false);
System.out.println("b="+b+"c="+c);
A. a=true b=false
B. a=true b=false
C. a=true b=true
D. a=false b=false
[单项选择]下面程序段的输出结果是
public class Test
public static void main(String args[])
int x,y;
x=(int)Math.sqrt(5)/2+(int)Math.random( )*5/2;
y=(int)Math.sqrt(3)/2+(int)Math.random( )*3/2;
if(x>y)
System.out.println("x>y");
else if(x==y)
System.out.println("x=y");
else
System.out.println("x<y");
A. x>y
B. x=y
C. x<y
D. 编译错误