站内搜索
SCJP程序员认证考试 问题列表
问题 填空题3. string foo = “ABCDE”;  4. foo.substring(3);   5. foo.concat(“XYZ”);   6.   Type the value of foo at line 6.()

问题 单选题public class X implements Runnable(    private int x;   private int y;   public static void main(Stringargs)  X that = new X();   (new Thread(that)).start();  (new Thread(that)).start();  )  public void run() (  for (;;) (  x++;   y++;   System.out.printIn(“x=” + x + “, y = ” + y);   )   )   What is the result?()A  Errors at lines 7 and 8 cause compilation to fail.B  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”).C  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=1, y=1”).D  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 only for once (for example, “x=1, y=1”  followed by “x=2, y=2”).

问题 单选题int i = 0;  while (true) { if(i==4) {  break;  }  ++i;  }  System.out.println(“i=”+i);  What is the result?()A  i = 0B  i = 3C  i = 4D  i = 5E  Compilation fails.

问题 单选题1. public class ForBar  {  2. public static void main(String []args)   {  3.   int i = 0, j = 5;  4. tp: for (;;)  {  5. i ++;  6. for(;;)  7. if(i  --j) break tp;  8. }  9. system.out.printIn(“i = ” + i + “, j = “+ j);  10. }  11. }   What is the result?()A  The program runs and prints “i=1, j=0”B  The program runs and prints “i=1, j=4”C  The program runs and prints “i=3, j=4”D  The program runs and prints “i=3, j=0”E  An error at line 4 causes compilation to fail.F  An error at line 7 causes compilation to fail.

问题 单选题Which gets the name of the parent directory file “file.txt”?()A  String name= File.getParentName(“file.txt”);B  String name= (new File(“file.txt”)).getParent();C  String name = (new File(“file.txt”)).getParentName();D  String name= (new File(“file.txt”)).getParentFile();E  Directory dir=(new File (“file.txt”)).getParentDir();  String name= dir.getName();

问题 多选题11. public interface Status {  12. /* insert code here */ int MY_VALUE = 10;  13. }  Which three are valid on line 12?()AfinalBstaticCnativeDpublicEprivateFabstractGprotected

问题 多选题Which of these are keywords in Java?()AdefaultBNULLCStringDthrowsElong

问题 单选题public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (RuntimeException ex) {  System.out.print(“B”);  }  catch (Exception ex1) {  System.out.print(“C”);  }   finally {  System.out.print(“D”);  }  System.out.print(“E”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result?()A  BDB  BCDC  BDED  BCDEE  ABCDEF  Compilation fails.

问题 单选题public class X {   public object m () {   object o = new float (3.14F);   object oa = new object [1];   oa[0]= o;   o = null;   oa[0] = null;   return o;   }   }   When is the float object created in line 3, eligible for garbage collection?()A  Just after line 5.B  Just after line 6.C  Just after line 7.D  Just after line 8(that is, as the method returns).

问题 单选题Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?()   class A {}   class B extends A {}   class C extends A {}   public class Q3ae4 {   public static void main(String args[]) {   A x = new A();   B y = new B();   C z = new C();   // insert statement here   }   }A x = y;B z = x;C y = (B) x;D z = (C) y;E y = (A) y;

问题 多选题Which two valid declarations of a char? ()AChar ch = “a”;BChar ch = ‘“‘ ‘;CChar ch = ‘cafe‘;DChar ch = “cafe”;EChar ch = ‘“ucafe‘;FChar ch = ‘“u10100‘;GChar ch = (char) true;

问题 填空题5. String foo = “base”;   6. foo.substring(0,3);   7. foo.concat(“ket”)  8.   Type the value of foo at line 8.()

问题 多选题Which two valid declarations of a char?()AChar ch = “a”;BChar ch = ‘/’ ‘;CChar ch = ‘cafe’;DChar ch = “cafe”;EChar ch = ‘/ucafe’;FChar ch = ‘/u10100’;GChar ch = (char) true;

问题 多选题AnInterface is an interface.   AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.   AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that  takes one int argument.   Which two construct an anonymous inner class? ()AAnAdapter1 aa=new AnAdapter1(){}BAnAdapter0 aa=new AnAdapter0(){}CAnAdapter0 aa=new AnAdapter0(5){}DAnAdapter1 aa=new AnAdapter1(5){}EAnInterface a1=new AnInterface(5){}

问题 多选题Which two CANNOT directly cause a thread to stop executing?()ACalling the yield method.BCalling the wait method on an object.CCalling the notify method on an object.DCalling the notifyAll method on an object.ECalling the start method on another Thread object.