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

题目

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 行出现一个错误,编译失败

相似考题
更多“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(”相关问题
  • 第1题:

    Which declarations will allow a class to be started as a standalone program?()  

    • A、public void main(String args[])
    • B、public void static main(String args[])
    • C、public static main(String[] argv)
    • D、final public static void main(String [] array)
    • E、public static void main(String args[])

    正确答案:D,E

  • 第2题:

    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

  • 第3题:

    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

  • 第4题:

    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

  • 第5题:

    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

  • 第6题:

    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

  • 第7题:

    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

  • 第8题:

    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

  • 第9题:

    ATCRBS/DABS全呼叫信号中()。

    • A、P1、P2、P3、P4脉冲的幅度均相等
    • B、P1、P2、P3、P4脉冲的宽度均相等
    • C、P1、P4、P3的宽度相等,但P2较宽
    • D、P1、P3、P2的宽度相等,但P4较宽

    正确答案:D

  • 第10题:

    单选题
    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
    解析: 暂无解析

  • 第11题:

    多选题
    现有:  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
    解析: 暂无解析

  • 第12题:

    单选题
    public class Base {  public static final String FOO = “foo”;  public static void main(String[] args) {  Base b = new Base();  Sub s = new Sub();  System.out.print(Base.FOO);  System.out.print(Sub.FOO);  System.out.print(b.FOO);  System.out.print(s.FOO);  System.out.print(((Base)s).FOO);  } }  class Sub extends Base {public static final String FOO=bar;}  What is the result?()
    A

     foofoofoofoofoo

    B

     foobarfoobarbar

    C

     foobarfoofoofoo

    D

     foobarfoobarfoo

    E

     barbarbarbarbar

    F

     foofoofoobarbar

    G

     foofoofoobarfoo


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

  • 第13题:

    public class Base {  public static final String FOO = “foo”;  public static void main(String[] args) {  Base b = new Base();  Sub s = new Sub();  System.out.print(Base.FOO);  System.out.print(Sub.FOO);  System.out.print(b.FOO);  System.out.print(s.FOO);  System.out.print(((Base)s).FOO);  } }  class Sub extends Base {public static final String FOO=bar;}  What is the result?() 

    • A、 foofoofoofoofoo
    • B、 foobarfoobarbar
    • C、 foobarfoofoofoo
    • D、 foobarfoobarfoo
    • E、 barbarbarbarbar
    • F、 foofoofoobarbar
    • G、 foofoofoobarfoo

    正确答案:D

  • 第14题:

    现有:  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

  • 第15题:

    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

  • 第16题:

    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

  • 第17题:

    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

  • 第18题:

    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

  • 第19题:

    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

  • 第20题:

    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

  • 第21题:

    单选题
    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())


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

  • 第22题:

    多选题
    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
    解析: 暂无解析

  • 第23题:

    单选题
    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
    解析: 暂无解析