题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-05-26 07:09:55

[单项选择] package foo;  import java.util.Vector; private class MyVector extends Vector {  int i = 1;  public MyVector() {  i = 2; } }  public class MyNewVector extends MyVector {  public MyNewVector() {  i = 4;  }  public static void main(String args[]) {  MyVector v = new MyNewVector();  }  }  What is the result?()
A.  Compilation succeeds.
B.  Compilation fails because of an error at line 5.
C.  Compilation fails because of an error at line 6.
D.  Compilation fails because of an error at line 14.
E.  Compilation fails because of an error at line 17.

更多"package foo;  import&ensp"的相关试题:

[多项选择]  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 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.
[单项选择] class Foo {  private int x;  publicFoo(intx) {this.x=x; }  public void setX( int x) { this.x = x; }  public int getX() { return x; }  }   public class Gamma {  static Foo fooBar( Foo foo) {  foo = new Foo( 100);  return foo;  }  public static void main( String[] args) {  Foo foo = new Foo( 300);  System.out.print( foo.getX() + “-“);  Foo fooFoo = fooBar( foo);  System.out.print( foo.getX() + “-“);  System.out.print( fooFoo.getX() + “-“);  foo = fooBar( fooFoo);  System.out.print( foo.getX() + “-“);  System.out.prmt( fooFoo.getX());  }  }  What is the output of this program?()
A.  300-100-100-100-100
B.  300-300-100-100-100
C.  300-300-300-100-100
D.  300-300-300-300-100
[单项选择] 现有:  class Foo  {  public static void main (String  []  args)  {      int x=O;      int y=4;  for (int  z=0;  z<3;  Z++;  X++)  {     if(x>1&++y<10)    y++;    }  System. out .println (y);  }   }  结果是什么?()     
A. 7
B. 8
C. 10
D. 12
[单项选择] public class Foo implements Runnable (  public void run (Thread t) {  system.out.printIn(“Running.”);  }  public static void main (String[] args)  {  new thread (new Foo()).start();  } )   What is the result?()      
A.  An exception is thrown.
B.  The program exists without printing anything.
C.  An error at line 1 causes compilation to fail.
D.  An error at line 2 causes the compilation to fail.
E.  “Running” is printed and the program exits.
[单项选择]  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
[单项选择] 10. public class Foo implements java.io.Serializable {  11. private int x;  12. public int getX() { return x; }  12.publicFoo(int x){this.x=x; }  13. private void writeObject( ObjectOutputStream s)  14. throws IOException {  15. // insert code here  16. }  17. }  Which code fragment, inserted at line 15, will allow Foo objects to be correctly serialized and deserialized?() 
A.  s.writeInt(x);
B.  s.serialize(x);
C.  s.writeObject(x);
D.  s.defaultWriteObject();
[单项选择] 2. public class Foo implements Runnable (  3. public void run (Thread t) {  4. system.out.printIn(“Running.”);  5. }  6. public static void main (String[] args)  {  7. new thread (new Foo()).start(); 8. )  9. )   What is the result?()      
A.  An exception is thrown.
B.  The program exists without printing anything.
C.  An error at line 1 causes compilation to fail.
D.  An error at line 6 causes the compilation to fail.
E.  “Running” is printed and the program exits.
[单项选择]  public class Foo implements Runnable (   public void run (Thread t) {   system.out.printIn(“Running.”);   }   public static void main (String args) {   new thread (new Foo()).start();   }   )   What is the result?()  
A.  An exception is thrown.
B.  The program exists without printing anything.
C.  An error at line 1 causes compilation to fail.
D.  An error at line 2 causes the compilation to fail.
E.  “Running” is printed and the program exits.
[单项选择] 10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  Which code, inserted at line 15, allows the class Sprite to compile?() 
A.  Foo { public int bar() { return 1; } }
B.  new Foo { public int bar() { return 1; } }
C.  newFoo() { public int bar(){return 1; } }
D.  new class Foo { public int bar() { return 1; } }
[单项选择] 10. interface Foo {}  11. class Alpha implements Foo {}  12. class Beta extends Alpha {}  13. class Delta extends Beta {  14. public static void main( String[] args) {  15. Beta x = new Beta();  16. // insert code here  17. }  18. }  Which code, inserted at line 16, will cause a java.lang.ClassCastException?() 
A.  Alpha a = x;
B.  Foo f= (Delta)x;
C.  Foo f= (Alpha)x;
D.  Beta b = (Beta)(Alpha)x;
[单项选择] interface foo {   int k = 0;   }    public class test implements Foo (   public static void main(String args) (    int i;   Test test = new test ();   i= test.k;   i= Test.k;   i= Foo.k;   )   )   What is the result? ()
A.  Compilation succeeds.
B.  An error at line 2 causes compilation to fail.
C.  An error at line 9 causes compilation to fail.
D.  An error at line 10 causes compilation to fail.
E.  An error at line 11 causes compilation to fail.
[单项选择] package foo;  public class Outer (   public static class Inner (   )   )   Which statement is true?()  
A.  An instance of the Inner class can be constructed with “new Outer.Inner()”
B.  An instance of the inner class cannot be constructed outside of package foo.
C.  An instance of the inner class can only be constructed from within the outer class.
D.  From within the package bar, an instance of the inner class can be constructed with “new inner()”
[多项选择] 10. class Foo {  11. static void alpha() { /* more code here */ }  12. void beta() { /* more code here */ }  13. }  Which two are true?()
A.  Foo.beta() is a valid invocation of beta().
B.  Foo.alpha() is a valid invocation of alpha().
C.  Method beta() can directly call method alpha().
D.  Method alpha() can directly call method beta().

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码