网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
public class SomeException {  } Class a:  public class a {  public void doSomething() { }  } Class b:  public class b extends a {  public void doSomething() throws SomeException { }  }  Which is true about the two classes?()
A

 Compilation of both classes will fail.

B

 Compilation of both classes will succeed.

C

 Compilation of class a will fail. Compilation of class b will succeed.

D

 Compilation of class a will fail. Compilation of class a will succeed.


参考答案

参考解析
解析: 暂无解析
更多 “单选题public class SomeException {  } Class a:  public class a {  public void doSomething() { }  } Class b:  public class b extends a {  public void doSomething() throws SomeException { }  }  Which is true about the two classes?()A  Compilation of both classes will fail.B  Compilation of both classes will succeed.C  Compilation of class a will fail. Compilation of class b will succeed.D  Compilation of class a will fail. Compilation of class a will succeed.” 相关考题
考题 单选题You want subclasses in any package to have access to members of a superclass. Which is the mostrestrictive access modifier that will accomplish this objective?()A  PublicB  PrivateC  ProtectedD  TransientE  No access modifier is qualified

考题 单选题public class Foo {  public static void main(String[] args) {  try {  return;  } finally {  System.out.println( “Finally” );  }  }  }  What is the result?()A  FinallyB  Compilation fails.C  The code runs with no output.D  An exception is thrown at runtime.

考题 单选题What does the value returned by the method getID() found in class java.awt.AWTEvent uniquely identify?()A The particular event instance.B The source of the event.C The set of events that were triggered by the same action.D The type of event.E The type of component from which the event originated.

考题 单选题public class test(    public int aMethod()[   static int i=0;   i++;   return I;   )    public static void main (String args){   test test = new test();    test.aMethod();   int j = test.aMethod();   System.out.printIn(j);   ]  }   What is the result?()A  Compilation will fail.B  Compilation will succeed and the program will print “0”C  Compilation will succeed and the program will print “1”D  Compilation will succeed and the program will print “2”

考题 多选题Which declarations will allow a class to be started as a standalone program?()Apublic void main(String args[])Bpublic void static main(String args[])Cpublic static main(String[] argv)Dfinal public static void main(String [] array)Epublic static void main(String args[])

考题 单选题Given the command line java Pass2 and:  public class Pass2 {  public void main(String [] args) {  int x=6;  Pass2 p = new Pass2();  p.doStuff(x);  System.out.print(” main x = “+ x); }  void doStuff(int x) {  System.out.print(” doStuffx = “+ x++);  }  }  What is the result?()A  Compilation fails.B  An exception is thrown at runtime.C  doStuffx = 6 main x = 6D  doStuffx = 6 main x = 7E  doStuffx = 7 main x = 6F  doStuffx = 7 main x = 7

考题 单选题public class ArrayTest {   public static void main (Stringargs) {   float f1, f2;   f1 = new float [10];  f2 = f1;   System.out.printIn (“f2[0]=” + f2[0]);   }  }   What is the result?()A  It prints f2[0] = 0.0B  It prints f2[0] = NaNC  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 exception at runtime.

考题 单选题1. class A {  2. public byte getNumber ()  {  3.   return 1;  4.   }  5. }  6.    7. class B extends A {  8. public short getNumber()  {  9.  return 2;  10. }  11.    12. public static void main (String args[]) {   13.    B  b = new B ();  14.      System.out.printIn(b.getNumber())     15.   }  16. }    What is the result?()A  Compilation succeeds and 1 is printed.B  Compilation succeeds and 2 is printed.C  An error at line 8 causes compilation to fail.D  An error at line 14 causes compilation to fail.E  Compilation succeeds but an exception is thrown at line 14.

考题 单选题public class test (    public static void main (String args) {    int i = 0xFFFFFFF1;  int j = ~i;   }    )   What is the decimal value of j at line 5?()A  0B  1C  14D  –15E  An error at line 3 causes compilation to fail.F  An error at line 4 causes compilation to fail.

考题 多选题Which three are valid declarations of a float? ()AFloat foo = -1;BFloat foo = 1.0;CFloat foo = 42e1;DFloat foo = 2.02f;EFloat foo = 3.03d;FFloat foo = 0x0123;

考题 多选题1. class Super {  2. private int a;  3. protected Super(int a) { this.a = a; }  4. }  .....  11. class Sub extends Super {  12. public Sub(int a) { super(a); }  13. public Sub() { this.a= 5; }  14. }  Which two, independently, will allow Sub to compile?()AChange line 2 to: public int a;BChange line 2 to: protected int a;CChange line 13 to: public Sub() { this(5); }DChange line 13 to: public Sub() { super(5); }EChange line 13 to: public Sub() { super(a); }

考题 单选题12. String csv = “Sue,5,true,3”;  13. Scanner scanner = new Scanner( csv);  14. scanner.useDelimiter(”,”);  15. int age = scanner.nextInt();  What is the result?()A  Compilation fails.B  After line 15, the value of age is 5.C  After line 15, the value of age is 3.D  An exception is thrown at runtime.

考题 单选题//point X  public class foo { public static void main (String[]args) throws Exception {  java.io.printWriter out = new java.io.PrintWriter {  new java.io.outputStreamWriter (System.out), true;  out.printIn(“Hello”); }  }  }   Which statement at PointX on line 1 allows this code to compile and run?()A  Import java.io.*;B  Include java.io.*;C  Import java.io.PrintWriter;D  Include java.io.PrintWriter;E  No statement is needed.

考题 单选题public class Test {  public static void main(String [] args) {  System.out.println(args.length  4   args[4].equals(“-d”));  }  }   If the program is invoked using the command line: java Test One Two Three –d   What is the result?()A  trueB  falseC  Compilation fails.D  An exception is thrown at runtime.

考题 单选题Given an ActionEvent, which method allows you to identify the affected Component?()A  Public class getClass()B  Public Object getSource()C  Public Component getSource()D  Public Component getTarget()E  Public Component getComponent()F  Public Component getTargetComponent()

考题 单选题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  testB  nullC  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.

考题 多选题Given the following interface definition, which definitions are valid?()   interface I {   void setValue(int val);   int getValue();   }    DEFINITION a:   (a) class a extends I {  int value;   void setValue(int val) { value = val;  }   int getValue() {  return value;  }   }   DEFINITION b:   (b) interface b extends I {   void increment();   }   DEFINITION c:   (c) abstract class c implements I {   int getValue() {  return 0;  }  abstract void increment();   }   DEFINITION d:   (d) interface d implements I {  void increment();  }   DEFINITION e:   (e) class e implements I {  int value;   public void setValue(int val) { value = val; }  }ADefinition a.BDefinition b.CDefinition c.DDefinition d.EDefinition e.

考题 单选题public class SyncTest {  private int x;   private int y;   public synchronized void setX (int i) (x=1;)   public synchronized void setY (int i) (y=1;)   public synchronized void setXY(int 1)(set X(i); setY(i);)   public synchronized Boolean check() (return x !=y;)   }   Under which conditions will check () return true when called from a different class?A  Check() can never return true.B  Check() can return true when setXY is called by multiple threads.C  Check() can return true when multiple threads call setX and setY separately.D  Check() can only return true if SyncTest is changed to allow x and y to be set separately.

考题 单选题public class foo {   public static void main (stringargs)   try {return;}   finally {system.out.printIn(“Finally”);}   }     What is the result?()A  The program runs and prints nothing.B  The program runs and prints “Finally”C  The code compiles, but an exception is thrown at runtime.D  The code will not compile because the catch block is missing.

考题 单选题public class foo {  static String s;  public static void main (String[]args) {  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.

考题 单选题Consider the following class:     class Test(int i) {     void test(int i) {  System.out.println(“I am an int.”); }    void test(String s) {   System.out.println(“I am a string.”);     }          public static void main(String args) {    Test t=new Test();     char ch=“y”;    t.test(ch);     }      }     Which of the statements below is true?()A  Line 5 will not compile, because void methods cannot be overridden.B  Line 12 will not compile, because there is no version of test() that rakes a charargument.C  The code will compile but will throw an exception at line 12.D  The code will compile and produce the following output: I am an int.E  The code will compile and produce the following output: I am a String.

考题 单选题Which of the following answer is correct to express the value 8 in octal number?()A  010B  0x10C  08D  0x8

考题 单选题public class test (   public static void main(string args) {   int 1= 0;   while (i) {   if (i==4) {   break;  }   ++i;  }   }   )   What is the value of i at line 10?()A  0B  3C  4D  5E  The code will not compile.

考题 单选题Under which circumstances will a thread stop?()A The method waitforId() in class MediaTracker is called.B The run() method that the thread is executing ends.C The call to the start() method of the Thread object returns.D The suspend() method is called on the Thread object.E The wait() method is called on the Thread object.

考题 单选题int index = 1;   int foo = new int ;   int bar = foo [index];   int baz = bar + index;   What is the result?()A  Baz has the value of 0B  Baz has the value of 1C  Baz has the value of 2D  An exception is thrown.E  The code will not compile.

考题 单选题public class X implements Runnable (   private int x;   private int y;    public static void main(String args) (   X that = new X();   (new Thread(that)) . start( );   (new Thread(that)) . start( );   )    public synchronized void run( ) (    for (;;) (    x++;    y++;    System.out.printIn(“x = “ + x + “, y = “ + y);    )   )    )   What is the result?()A  An error at line 11 causes compilation to fail.B  Errors at lines 7 and 8 cause compilation to fail.C  The program prints pairs of values for x and y that might not always be the same on the same line  (for example, “x=2, y=1”)D  The program prints pairs of values for x and y that are always the same on the same line (forexample, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by  “x=1, y=1”)E  The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by  “x=2s, y=2”)

考题 单选题String a = “ABCD”;  String b = a.toLowerCase();  b.replace(‘a’, ‘d’);  b.replace(‘b’, ‘c’);  System.out.println(b);   What is the result? ()A  abcdB  ABCDC  dccdD  dcbaE  Compilation fails.F  An exception is thrown at runtime.

考题 单选题1. public class GoTest {  2. public static void main(String[] args) {  3. Sente a = new Sente(); a.go();  4. Goban b = new Goban(); b.go();  5. Stone c = new Stone(); c.go();  6. }  7. } 8.  9. class Sente implements Go {  10. public void go() { System.out.println(”go in Sente.”); }  11. }  12.  13. class Goban extends Sente {  14. public void go() { System.out.println(”go in Goban”); }  15. }  16.  17. class Stone extends Goban implements Go { }  18.  19. interface Go { public void go(); }  What is the result?()A  go in Goban  go in Sente go in SenteB  go in Sente  go in Sente go in GobanC  go in Sente  go in Goban go in GobanD  go in Goban go in Goban go in SenteE  Compilation fails because of an error in line 17.