单选题5. class Passer3 {   6. final static Passer3 p2 = new Passer3();   7. public static void main(String [] args) {   8. Passer3 p4 = p2.go(p2);   9. Passer3 p3 = p2;   10. System.out.print(p3==p4);   11. }   12. Passer3 go(Passer3 p) {   13. p = new Passe

题目
单选题
5. class Passer3 {   6. final static Passer3 p2 = new Passer3();   7. public static void main(String [] args) {   8. Passer3 p4 = p2.go(p2);   9. Passer3 p3 = p2;   10. System.out.print(p3==p4);   11. }   12. Passer3 go(Passer3 p) {   13. p = new Passer3();   14. return p;   15. }   16. }   结果为:()
A

true

B

false

C

第 8 行出现一个错误,编译失败

D

第 9 行出现一个错误,编译失败


相似考题
参考答案和解析
正确答案: D
解析: 暂无解析
更多“单选题5. class Passer3 {   6. final static Passer3 p2 = new Passer3();   7. public static void main(String [] args) {   8. Passer3 p4 = p2.go(p2);   9. Passer3 p3 = p2;   10. System.out.print(p3==p4);   11. }   12. Passer3 go(Passer3 p) {   13. p = new Passe”相关问题
  • 第1题:

    Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()

    • A、p0 = p1;
    • B、p1 = p2;
    • C、p2 = p4;
    • D、p2 = (ClassC)p1;
    • E、p1 = (ClassB)p3;
    • F、p2 = (ClassC)p4;

    正确答案:A,E,F

  • 第2题:

    1. class Pizza {  2. java.util.ArrayList toppings;  3. public final void addTopping(String topping) {  4. toppings.add(topping); 5. }  6. }  7. public class PepperoniPizza extends Pizza {  8. public void addTopping(String topping) {  9. System.out.println(”Cannot add Toppings”);  10. }  11. public static void main(String[] args) {  12. Pizza pizza = new PepperoniPizza();  13. pizza.addTopping(”Mushrooms”);  14. }  15. }  What is the result?() 

    • A、 Compilation fails.
    • B、 Cannot add Toppings
    • C、 The code runs with no output.
    • D、 A NullPointerException is thrown in Line 4.

    正确答案:A

  • 第3题:

    1. public class Test { 2. public static String output =””; 3.  4. public static void foo(int i) { 5. try { 6. if(i==1) { 7. throw new Exception(); 8. } 9. output += “1”; 10. } 11. catch(Exception e) { 12. output += “2”; 13. return; 14. } 15. finally { 16. output += “3”;17. } 18. output += “4”; 19. } 20.  21. public static void main(String args[]) { 22. foo(0); 23. foo(1); 24.  25. }26. } What is the value of the variable output at line 23?()


    正确答案:13423

  • 第4题:

    1. class Passer2 {   2. //insert code here   3. static int bigState = 42;   4. public static void main(String [] args) {   5. bigState = p2.go(bigState);   6. System.out.print(bigState);   7. }   8. int go(int x) {   9. return ++x;   10. }   11. }  和4段代码片段:  static Passer2 p2 = new Passer2();  final static Passer2 p2 = new Passer2();  private static Passer2 p2 = new Passer2();  final private static Passer2 p2 = new Passer2();  有多少行分别插入到第2行,可以编译?()  

    • A、0
    • B、1
    • C、3
    • D、4

    正确答案:D

  • 第5题:

    class Passer {  static final int x = 5;  public static void main(String [] args) { new Passer().go(x);  System.out.print(x);  }  void go(int x) {  System.out.print(++x);  }  }  结果是什么?() 

    • A、55
    • B、56
    • C、65
    • D、66

    正确答案:C

  • 第6题:

    1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()

    • A、 0
    • B、 3
    • C、 4
    • D、 5
    • E、 The code will not compile.

    正确答案:E

  • 第7题:

    1. class Bar { }  1. class Test {  2. Bar doBar() {  3. Bar b = new Bar();  4. return b;  5. }  6. public static void main (String args[]) {  7. Test t = new Test();  8. Bar newBar = t.doBar();  9. System.out.println(“newBar”);  10. newBar = new Bar();  11. System.out.println(“finishing”);  12. }  13. } At what point is the Bar object, created on line 3, eligible for garbage collection?()  

    • A、 After line 8.
    • B、 After line 10.
    • C、 After line 4, when doBar() completes.
    • D、 After line 11, when main() completes.

    正确答案:B

  • 第8题:

    单选题
    1. class Pizza {  2. java.util.ArrayList toppings;  3. public final void addTopping(String topping) {  4. toppings.add(topping); 5. }  6. }  7. public class PepperoniPizza extends Pizza {  8. public void addTopping(String topping) {  9. System.out.println(”Cannot add Toppings”);  10. }  11. public static void main(String[] args) {  12. Pizza pizza = new PepperoniPizza();  13. pizza.addTopping(”Mushrooms”);  14. }  15. }  What is the result?()
    A

     Compilation fails.

    B

     Cannot add Toppings

    C

     The code runs with no output.

    D

     A NullPointerException is thrown in Line 4.


    正确答案: D
    解析: 暂无解析

  • 第9题:

    单选题
    5. class Passer3 {   6. final static Passer3 p2 = new Passer3();   7. public static void main(String [] args) {   8. Passer3 p4 = p2.go(p2);   9. Passer3 p3 = p2;   10. System.out.print(p3==p4);   11. }   12. Passer3 go(Passer3 p) {   13. p = new Passer3();   14. return p;   15. }   16. }   结果为:()
    A

    true

    B

    false

    C

    第 8 行出现一个错误,编译失败

    D

    第 9 行出现一个错误,编译失败


    正确答案: B
    解析: 暂无解析

  • 第10题:

    多选题
    现有:  class ClassA  {}  class ClassB extends ClassA  {)      class ClassC extends ClassA  {)     以及:  ClassA p0=new ClassA();      ClassB pl=new ClassB();      ClassC p2=new ClassC();     ClassA p3=new ClassB();    ClassA p4=new ClassC(); 下列哪些是正确的?()
    A

    p0=pl;

    B

    p1 =p2;

    C

    p2=p4;

    D

    p2 = (ClassC)pl;

    E

    p1 = (ClassB)p3;

    F

    p2 =  (Classc)p4;


    正确答案: A,F
    解析: 暂无解析

  • 第11题:

    单选题
    class Passer {  static final int x = 5;  public static void main(String [] args) { new Passer().go(x);  System.out.print(x);  }  void go(int x) {  System.out.print(++x);  }  }  结果是什么?()
    A

    55

    B

    56

    C

    65

    D

    66


    正确答案: D
    解析: 暂无解析

  • 第12题:

    单选题
    1. class Passer2 {   2. //insert code here   3. static int bigState = 42;   4. public static void main(String [] args) {   5. bigState = p2.go(bigState);   6. System.out.print(bigState);   7. }   8. int go(int x) {   9. return ++x;   10. }   11. }  和4段代码片段:  static Passer2 p2 = new Passer2();  final static Passer2 p2 = new Passer2();  private static Passer2 p2 = new Passer2();  final private static Passer2 p2 = new Passer2();  有多少行分别插入到第2行,可以编译?()
    A

    0

    B

    1

    C

    3

    D

    4


    正确答案: D
    解析: 暂无解析

  • 第13题:

    现有:  class ClassA  {}  class ClassB extends ClassA  {)      class ClassC extends ClassA  {)     以及:  ClassA p0=new ClassA();      ClassB pl=new ClassB();      ClassC p2=new ClassC();     ClassA p3=new ClassB();    ClassA p4=new ClassC(); 下列哪些是正确的?()

    • A、p0=pl;
    • B、p1 =p2;
    • C、p2=p4;
    • D、p2 = (ClassC)pl;
    • E、p1 = (ClassB)p3;
    • F、p2 =  (Classc)p4;

    正确答案:A,E,F

  • 第14题:

    1. import java.util.*;  2. class ForInTest {  3. static List list = new ArrayList();  4.  5. static List getList() { return list; }  6.  7. public static void main(String [] args) {  8. list.add("a"); list.add("b"); list.add("c");  9. // insert code here  10. System.out.print(o);  11. }  12. } 第 9 行插入哪一项将输出 abc?() 

    • A、for(char o: list)
    • B、for(Object o: getList())
    • C、for(Object o: getList();)
    • D、for(Object o: o.getList())

    正确答案:B

  • 第15题:

    1. class A {  2. public String toString ()  {  3. return “4”;  4. }  5. }  6. class B extends A {  7. public String toString ()   {  8. return super.toString()  + “3”;  9. }  10. }  11. public class Test {  12.   public static void main(String[]args)  {  13.      System.out.printIn(new B());  14.      }  15. }    What is the result?()  

    • A、 Compilation succeeds and 4 is printed.
    • B、 Compilation succeeds and 43 is printed.
    • C、 An error on line 9 causes compilation to fail.
    • D、 An error on line 14 causes compilation to fail.
    • E、 Compilation succeeds but an exception is thrown at line 9.

    正确答案:B

  • 第16题:

    1. class MyThread implements Runnable {  2. public void run() {  3. System.out.print("go ");  4. }  5.  6. public static void main(String [] args) {  7. // insert code here  8. t.start(); 9. }  10. }  和如下四句:  Thread t = new MyThread(); MyThread t = new MyThread();  Thread t = new Thread(new Thread());  Thread t = new Thread(new MyThread());  分别插入到第5行,有几个可以通过编译?() 

    • A、0
    • B、1
    • C、2
    • D、3

    正确答案:C

  • 第17题:

    1. class A {  3. public String to String() {  4. return “4”;  5. }  6. }  7. class B extends A {  8. public String toString() { 9. return super.toString() + “3”;  10. }  11. }  12. public class Test {  13. public static void main (String[] args) {  14. System.out.printIn(new B()); 15. }  16. }   What is the result( )?  

    • A、 Compilation succeeds and 4 is printed.
    • B、 Compilation …………… is printed.
    • C、 An error on line 9 cause compilation to fail.
    • D、 An error on line 14 cause compilation to fail.
    • E、 Compilation succeeds but an exception is thrown at line 9.

    正确答案:B

  • 第18题:

    class ClassA {}  class ClassB extends ClassA {}  class ClassC extends ClassA {}  and:  ClassA p0 = new ClassA();  ClassB p1 = new ClassB();  ClassC p2 = new ClassC();  ClassA p3 = new ClassB();  ClassA p4 = new ClassC();  Which three are valid?()

    • A、 p0 = p1;
    • B、 p1 =p2;
    • C、 p2 = p4;
    • D、 p2 = (ClassC)p1;
    • E、 p1 = (ClassB)p3;
    • F、 p2 = (ClassC)p4;

    正确答案:A,E,F

  • 第19题:

    单选题
    1. class A {  2. public String toString ()  {  3. return “4”;  4. }  5. }  6. class B extends A {  7. public String toString ()   {  8. return super.toString()  + “3”;  9. }  10. }  11. public class Test {  12.   public static void main(String[]args)  {  13.      System.out.printIn(new B());  14.      }  15. }    What is the result?()
    A

     Compilation succeeds and 4 is printed.

    B

     Compilation succeeds and 43 is printed.

    C

     An error on line 9 causes compilation to fail.

    D

     An error on line 14 causes compilation to fail.

    E

     Compilation succeeds but an exception is thrown at line 9.


    正确答案: C
    解析: 暂无解析

  • 第20题:

    单选题
    1. class MyThread implements Runnable {  2. public void run() {  3. System.out.print("go ");  4. }  5.  6. public static void main(String [] args) {  7. // insert code here  8. t.start(); 9. }  10. }  和如下四句:  Thread t = new MyThread(); MyThread t = new MyThread();  Thread t = new Thread(new Thread());  Thread t = new Thread(new MyThread());  分别插入到第5行,有几个可以通过编译?()
    A

    0

    B

    1

    C

    2

    D

    3


    正确答案: A
    解析: 暂无解析

  • 第21题:

    多选题
    Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()
    A

    p0 = p1;

    B

    p1 = p2;

    C

    p2 = p4;

    D

    p2 = (ClassC)p1;

    E

    p1 = (ClassB)p3;

    F

    p2 = (ClassC)p4;


    正确答案: D,A
    解析: 暂无解析

  • 第22题:

    单选题
    3. import java.util.*;   4. class ForInTest {   5. static List list = new ArrayList();   6.   7. public static void main(String [] args) {   8. list.add("a"); list.add("b"); list.add("c");   9. //insert code here   10. System.out.print(o);   11. }   12. }   哪一行插入到第9行将导致输出“abc”?()
    A

     for(Object o : list)

    B

     for(Iterator o : list)

    C

     for(Object o : list.iterator())

    D

     for(Iterator o : list.iterator(); o.hasNext (); )


    正确答案: A
    解析: 暂无解析

  • 第23题:

    单选题
    1. class A {  3. public String to String() {  4. return “4”;  5. }  6. }  7. class B extends A {  8. public String toString() { 9. return super.toString() + “3”;  10. }  11. }  12. public class Test {  13. public static void main (String[] args) {  14. System.out.printIn(new B()); 15. }  16. }   What is the result( )?
    A

     Compilation succeeds and 4 is printed.

    B

     Compilation …………… is printed.

    C

     An error on line 9 cause compilation to fail.

    D

     An error on line 14 cause compilation to fail.

    E

     Compilation succeeds but an exception is thrown at line 9.


    正确答案: B
    解析: 暂无解析

  • 第24题:

    单选题
    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 Sente

    B

     go in Sente      go in Sente go in Goban

    C

     go in Sente     go in Goban go in Goban

    D

     go in Goban    go in Goban go in Sente

    E

     Compilation fails because of an error in line 17.


    正确答案: D
    解析: 暂无解析