更多"[单选题]下列程序的输出结果是:
public class Tes"的相关试题:
[单选题]下列程序的输出结果是:
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;iA.Catch---1
B.Catch---2
C.Catch---3
D.以上都不对
[单选题]下列程序输出结果为:public class test {public static void main(String args[]) {int a = 0;outer:for(int i=0;i
A.2
B.3
C.4
D.0
[单选题]下列程序的运行结果是:
public class test{
private String[] data={"10","10.5"};
public void fun(){
double s=0;
for(int i=0;i<3;i++){
try{
s=s+Integer .parseInt(data[i]);
}catch(Exception e){
System.out.print("errorl:"+data[i]);
}
}
}
public static void main(String[]args){
try{
test d=new test();
d .fun();
}catch(Exception e){
System.out.println("error2");
}
}
}
A.errorl:10.5
B.error2
C.errorl:10.5 error2
D.以上都不对
[单选题]下列代码的执行结果是
public class Test
{ public int aMethod()
{ static int i=0; i++; System.out.println(i); }
public static void main(String args[])
{ Test test = new Test(); test.aMethod(); } }
A.编译错误
B.0
C.1
D.运行成功,但不输出
[单选题]下列代码的执行结果是:
public class Test {
public static void main(String[] args) {
int[] x={0,1,2,3};
for(int i=0;i<3;i+=2){
try{
System.out.println(x[i+2]/x[i]+x[i+1]);
}catch(ArithmeticException e){
System.out.println("error1");
}catch(Exception e){
System.out.println("error2");
}
}
}
}
A.error1
B.error2
C.error1
error2
D.2
error2
[单选题]阅读下列程序
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)值都出现两次。
B.每行的(x,y)中,可能有;每一对(x,y)值仅出现一次。
C.每行的(x,y)中,可能有x=y;每一对(x,y)值都出现两次。
D.每行的(x,y)中,可能有x=y;每一对(x,y)值都出现一次。