更多"public class TestA{ "的相关试题:
[单项选择] class TestA { public void start() { System.out.println(”TestA”); } } public class TestB extends TestA { public void start() { System.out.println(”TestB”); } public static void main(String[] args) { ((TestA)new TestB()).start(); } } What is the result?()
A. TestA
B. TestB
C. Compilation fails.
D. An exception is thrown at runtime.
[单项选择] 1. interface TestA { String toString(); } 2. public class Test { 3. public static void main(String[] args) { 4. System.out.println(new TestA() { 5. public String toString() { return “test”; } 6. } 7. } 8. } What is the result?()
A. test
B. null
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 1.
E. Compilation fails because of an error in line 4.
F. Compilation fails because of an error in line 5.
[单项选择] 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. 以上都不对
[单项选择] 程序: 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
[单项选择] 程序: class TestApp{ public static void main (String[] args){ int x=6; if (x>l) System. out. println("x>l"); else if (x>5) System. out .println("x>5"); else if (x<10) System. out. println("xSystem. out .println( "x<29"); else System. out.println(“以上都不是”); } } 上述程序运行后的结果是哪项?()
A. x>5
B. x>l
C. x<10
D. x<29
[多项选择] 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
[单项选择] 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.
[多项选择] 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”);
[单项选择] 现有: class TestA { public void start() { System.out.println("TestA"); } } public class TestB extends TestA { public void start() { System.out.println("TestB"); } public static void main (string[] args) ( ((TestA)new TestB()).start(); ) } 运行结果是哪项?()
A. TeStA
B. TeStB
C. 编译失败
D. 运行时抛出异常
[单项选择] 下面程序的输出结果是() 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
[多项选择]
下列解释正确的是()
A. out_applet.java中一定有一个参数是“display_string”
B.
具有两个属性“name”和“value”
C. value是参数的名称
D. “good morning”通过
标记传递给“Our_Applet.class”
[简答题] 一般程序如下: ORG 2000H ARY DW --4,3,--2,1 CNT DW $--ARY VAR DW ARY,$+4 ┆ MOV AX,ARY MOV BX,OFFSET VAR MOV CX,CNT MOV DX,VAR+2 LEA SI,ARY ┆ 此程序段执行后,寄存器AX,BX,CX,DX与SI中的内容各是多少?
[单项选择] 现有: 1 Interface F{} 2 class A implements F{} 3 class B extends A{} 4 class C extends B{ 5 public static void main(String[] args){ 6 B b=new B(); 7 //inSert C0de here 8 } 9 } 下列哪行代码插入到第7行,将抛出java.lang.ClassCaseException异常()
A. A a=b;
B. F f= (C)b;
C. F f= (A)b;
D. B bb= (B)(A)b;
[单项选择] 现有: class Pencil { public void write (String content){ System.out.println ("Write"+content); } } class RubberPencil extends Pencil{ public void erase (String content){ System.out.println ("Erase"+content); } } 执行下列代码的结果是哪项?() Pencil pen=new RubberPencil(); pen.write ("Hello"); pen.erase ("Hello");
A. Write Hello Erase Hello
B. Erase Hello Write Hello
C. 编译错误
D. 运行时抛出异常
[多项选择] public class Foo { private int val; public foo(int v) (val = v;) } public static void main (String args) { Foo a = new Foo (10); Foo b = new Foo (10); Foo c = a; int d = 10; double e = 10.0; } Which three logical expression evaluate to true? ()
A. (a ==c)
B. (d ==e)
C. (b ==d)
D. (a ==b)
E. (b ==c)
F. (d ==10.0)
[单项选择] public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(){ System.out.print(4); } public Dog(String name){ this(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()
A. 143
B. 423
C. 243
D. 1134