更多"程序:  class   Te"的相关试题:
[单项选择] 程序: class TestApp{ public static void main() String[] args){ for(int i=0;i<10;i++){ if(i==3) break; 当循环到3时,自动跳出 System.out.print(i); } } } 程序运行后的输出是哪项?()
A. 0123
B. 012
C. 0123456789
D. 012456789
[单项选择] public class TestA{ public void methodA() throws IOException{ //…… } } public class TestB extends TestA{ public void methodA() throws EOFException{ //…… } } public class TestC extends TestA{ public void methodA() throws Exception{ //…… } } 当编译类TestC的时候,结果是哪项?()
A. 正常
B. 编译错误
C. 运行错误
D. 以上都不对
[多项选择] public class test3 { public static void main(String args[]) { for(int i = 0; i < 3; i++) { for(int j = 3; j >= 0; j--) { if(i == j) continue; System.out.println("i="+ i + " j="+j); } } } } 上面的Java代码编译运行后,下列选项中,()会出现在输出结果中。
A. i=0 j=3
B. i=0 j=0
C. i=2 j=2
D. i=0 j=2
E. i=1 j=2
[单项选择] 程序: class TestApp{ int i public static void main(String[] args){ for(int i=0;i<5;i++) System.out.print(i+1); System.out.println(i); (i没有定义) } } 上述程序运行后的结果是哪项?()
A. 123456
B. 123455
C. 123450
D. 编译错误
[多项选择] public class TestString3 { public static void main(String[] args) { // insert code here System.out.println(s); } } Which two code fragments, inserted independently at line 3, generate the output 4247?()
A. String s = “123456789”; s = (s-”123”).replace(1,3,”24”) - “89”;
B. StringBuffer s = new StringBuffer(”123456789”); s.delete(0,3).replace( 1,3, “24”).delete(4,6);
C. StringBuffer s = new StringBuffer(”123456789”); s.substring(3,6).delete( 1 ,3).insert(1, “24”);
D. StringBuilder s = new StringBuilder(”123456789”); s.substring(3,6).delete( 1 ,2).insert( 1, “24”);
E. StringBuilder s = new StringBuilder(”123456789”); s.delete(0,3).delete( 1 ,3).delete(2,5).insert( 1, “24”);
[单项选择] 下面程序的输出结果是() public class Test{ public static void main(String[] args){ String s = “abc dsf ghi”; String[] arr = s.split(“/s”); System.out.println(arr.length); } }
A. 编译报错
B. 2
C. 1
D. 3
[单项选择] public class AssertStuff { public static void main(String [] args) { int x= 5; int y= 7; assert (x> y): “stuff”; System.out.println(”passed”); } } And these command line invocations:java AssertStuff java -ea AssertStuff What is the result?()
A. passed stuff
B. stuff passed
C. passed An AssertionError is thrown with the word “stuff” added to the stack trace.
D. passed An AssertionError is thrown without the word “stuff” added to the stack trace.
E. passed An AssertionException is thrown with the word “stuff” added to the stack trace.
F. passed An AssertionException is thrown without the word “stuff” added to the stack trace.
[单项选择] 程序: class TestApp{ public static void main(String[] args){ for(int i=0;i<5;i++) System.out.print(i+1); System.out.println(i); } } 上述程序运行后的结果是哪项?()
A. 123456
B. 123455
C. 123450
D. 编译错误
[单项选择] public class TestApp{ public int mymethod(){ try{ int i = 0; int j = 1 / i; System.out.println(“1”); }finally{ System.out.print(“4”); } return 1; } } 上述程序运行后的输出是哪项?()
A. 4
B. 14
C. 41
D. 以上都不对
[单项选择] public class TestApp{ public static void main(String[] args){ try{ String myname = null; if(myname.length()>2) System.out.print(“1”); }catch(NullPointerException e){ System.out.print(“2”); } } } 上述程序运行后的输出是哪项?()
A. 1
B. 12
C. 21
D. 2
[单项选择] class TestApp{ public static void main (String[ ] args){ for(int i=0;i<10;i++){ if(i==3) break; System.out.print (i); } } } 程序运行后的输出是哪项?()
A. 0123
B. 012
C. 0123456789
D. 012456789