下列程序的输出结果是( )。 Public class Test{ Public static void main(String[]args){ int[]array=(2,4,6,8,10); int size=6; int result=-l: try{ for(int i=0;i<sizeresult= =-1:) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch---1"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch---2"): } catch(Exception e){ System.out.println("Catch---3"): } }
A.Catch---1
B.Catch---2
C.Catch---3
D.以上都不对
第1题:
下列程序的运行结果是【 】。
public class Test {
public static void main (String args[]) {
String s1="hello!";
System.out.println (s1.toUpperCase());
}}
第2题:
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { for ( int a=0;a<10;a++) { if (a==5) break; System.out.println(A); } } }
A.01234
B.6789
C.012346789
D.5
第3题:
若有如下程序:
public class Test {
public static void main (String[] args) {
int x=20;
if (x>10) System.out.print(x-=5);
if (x>5) System.out.print(x--);
}
}则程序运行后的输出结果是【 】。
第4题:
下列程序的输出结果是_______。
class Test{
public static void main(String args []){
int m=6;
do{m--:}while(m>0);
System.out.println("m="+m);
}
}
第5题:
下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new Te
A.0
B.1
C.2
D.3
第6题:
如下程序的输出结果是( )。 public class Test { void printValue(int m) { do { System.out.println("The value is"+m); } while( --m>10) } public static void main(String args[]) { int i=10; Test t=new Test(); t.printValue(i); } }
A.The value is 8
B.The value is 9
C.The value is 10
D.The value is 11
第7题:
A.public static void main()
B.public static void main(String[] args)
C.public static int main(String[] args)
D.public void main(String[] args)
第8题:
下列程序段的输出结果是【 】。
public class Test {
void printValue(int m) {
do {
System.out.println("The value is"+m);
}while (--m>10);
}
public static void main (String args[]) {
int i=10;
Test t= new Test();
t.printValue(i);
}
}
第9题:
下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic 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.运行成功,但不输出
第10题:
下列代码的执行结果是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.运行成功,但不输出