更多"public class ConstOver&en"的相关试题:
[单项选择] public class Foo { public static void main (String args) { int i = 1; int j = i++; if ((i>++j) && (i++ ==j)) { i +=j; } } } What is the final value of i?()
A. 1
B. 2
C. 3
D. 4
E. 5
[单项选择] public class foo { public static void main (Stringargs) { String s; system.out.printIn (“s=” + s); } } What is the result?()
A. The code compiles and “s=” is printed.
B. The code compiles and “s=null” is printed.
C. The code does not compile because string s is not initialized.
D. The code does not compile because string s cannot be referenced.
E. The code compiles, but a NullPointerException is thrown when toString is called.
[单项选择] public class ArrayTest { public static void main(String[] args) { float fl[], f2[]; fl = new float[10]; f2 = f1; System.out.println(“f2[0]= “ + f2[0]); } } What is the result?()
A. It prints f2[0] = 0.0.
B. It prints f2[0] = NaN.
C. An error at line 5 causes compile to fail.
D. An error at line 6 causes compile to fail.
E. An error at line 6 causes an expectation at runtime.
[多项选择] public class Transfers { public static void main(String[] args) throws Exception { Record r1 = new Record(); Record r2 = new Record(); doTransfer(r1, r2, 5); doTransfer(r2, r1, 2); doTransfer(r1, r2, 1); // print the result System.out.println(”rl = “ + r1.get() +“, r2=” + r2.get()); } private static void doTransfer( final Record a, final Record b, final int amount) { Thread t = new Thread() { public void run() { new Clerk().transfer(a, b, amount); } }; t.start(); } } class Clerk { public synchronized void transfer(Record a, Record b, int amount){ synchronized (a) { synchronized (b) { a.add(-amount); b.add(amount); } } } } class Record { int num=10; public int get() { return num; } public void add(int n) { num = num + n; } } If Transfers.main() is run, which three are true?()
A. The output may be “r1 = 6, r2 = 14”.
B. The output may be “r1 = 5, r2 = 15”.
C. The output may be “r1 = 8, r2 = 12”.
D. The code may run (and complete) with no output.
E. The code may deadlock (without completing) with no output.
F. M IllegalStateException or InterruptedException may be thrown at runtime.
[单项选择] 现有: class Test2 f public static void main (String [] args) { boolean X= true; boolean y=false; short Z=20; if((x==true) && (y=true)) z++; if((y==true) || (++z==22)) z++; System. out .println( "z="+z); } 结果是什么?()
A. Z=21
B. Z=22
C. Z=23
D. Z= 24
[单项选择] 1. class Super { 2. public float getNum() { return 3.0f; } 3. } 4. 5. public class Sub extends Super { 6. 7. } Which method, placed at line6, causes compilation to fail?()
A. public void getNum(){}
B. public void getNum(double d){}
C. public float getNum() { return 4.0f; }
D. public double getNum(float d) { return 4.0d; }
[单项选择] 1. class super { 2. public float getNum() {return 3.0f;} 3. } 4. 5. public class Sub extends Super { 6. 7. } Which method, placed at line 6, will cause a compiler error?()
A. Public float getNum() {return 4.0f; }
B. Public void getNum () { }
C. Public void getNum (double d) { }
D. Public double getNum (float d) {retrun 4.0f; }
[多项选择]
下列解释正确的是()
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(String name){ System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()
A. 23
B. 13
C. 123
D. 321
[单项选择] 现有 public class Parentt public void change (int x){) ) public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?()
A. protected void change (int x){}
B. public void change(int x, int y){}
C. public void change (int x){}
D. public void change (String s){}