1. class TestA {  2. TestB b;  3. TestA() {  4. b = new Test

题目
多选题
1. class TestA {  2. TestB b;  3. TestA() {  4. b = new TestB(this);  5. }  6. }  7. class TestB {  8. TestA a;  9. TestB(TestA a) {  10. this.a = a;  11. }  12. }  13. class TestAll {  14. public static void main (String args[]) {  15. new TestAll().makeThings(); 16. // ...code continues on  17. }  18. void makeThings() {  19. TestA test = new TestA(); 20. }  21. }  Which two statements are true after line 15, before main completes?()
A

Line 15 causes a stack overflow.

B

An exception is thrown at runtime.

C

The object referenced by a is eligible for garbage collection.

D

The object referenced by b is eligible for garbage collection.

E

The object referenced by a is not eligible for garbage collection.

F

The object referenced by b is not eligible for garbage collection.

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Stringtest=TestA.TestB.TestC.”;12.//insertcodehere13.String[]result=test.split(regex);Whichregularexpressioninsertedatline12willcorrectlysplittestintoTestA,”TestB,”andTestC”?()

A.Stringregex=“”;

B.Stringregex=““;

C.Stringregex=“.*“.

D.Stringregex=“\\s”

E.Stringregex=“\\.\\s*”;

F.Stringregex=“\\w[\.]+“;


参考答案:E

第2题:

写出程序运行的结果

Public class Base

Public virtual string Hello() {return “Base”;}

Public class Sub:Base

Public override string Hello() {return “Sub”;}

1. Base b = new Base(); b.Hello;

2. Sub s = new Sub(); s.Hello;

3. Base b = new Sub (); b.Hello;

4. Sub s = new Base(); s.Hello;


正确答案:
 

第3题:

( 27 )有如下程序:

#include

using namespace std;

class test {

private:

int a;

public:

test () {cout<< ” constructor ” <<ENDL;}

test ( int a ) {cout<<A<<ENDL;}

test ( const test & _test )

{

a=_testa;

cout<< ” copy constructor ” <<ENDL;

}

test () {cout<< ” destructor ” <<ENDL;}

};

int main ()

}

test A ( 3 )

return0;

运行时输出的结果是

A ) 3

B ) constructor

destruclor

C ) copy constructor

dstructor

D ) 3

destruclor


正确答案:D

第4题:

public class TestA{    public void methodA() throws IOException{        //……    } }  public class TestB extends TestA{    public void methodA() throws EOFException{        //……   } }  public class TestC extends TestA{    public void methodA() throws Exception{        //……   } }  当编译类TestC的时候,结果是哪项?() 

  • A、 正常
  • B、 编译错误
  • C、 运行错误
  • D、 以上都不对

正确答案:B

第5题:

1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() 

  • A、 Line 4 of class Target can be changed to return i++;
  • B、 Line 2 of class Target can be changed to private int i = 1;
  • C、 Line 3 of class Target can be changed to private int addOne() {
  • D、 Line 2 of class Target can be changed to private Integer i = 0;

正确答案:D

第6题:

classTestA{publicvoidstart(){System.out.println(”TestA”);}}publicclassTestBextendsTestA{publicvoidstart(){System.out.println(”TestB”);}publicstaticvoidmain(String[]args){((TestA)newTestB()).start();}}Whatistheresult?()

A.TestA

B.TestB

C.Compilationfails.

D.Anexceptionisthrownatruntime.


参考答案:B

第7题:

第三题:请看如下代码

<%

TestString="Test"

TestA

TestB

Response.write TestString

Sub TestA()

TestString="TestA"

End Sub

Sub TestB()

Dim TestString

TestString="TestB"

End Sub

%>

这段代码执行后,运行结果是什么?并解释一下为什么?


正确答案:
  

第8题:

现有:classTestA{publicvoidstart(){System.out.println("TestA");}}publicclassTestBextendsTestA{publicvoidstart(){System.out.println("TestB");}publicstaticvoidmain (string[]args)(((TestA)newTestB()).start();)}运行结果是哪项?()

A.TeStA

B.TeStB

C.编译失败

D.运行时抛出异常


参考答案:B

第9题:

1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()

  • A、 Line 33 must be called within a try block.
  • B、 The exception thrown by method1 in class a is not required to be caught.
  • C、 The method declared on line 31 must be declared to throw a RuntimeException.
  • D、 On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.

正确答案:B

第10题:

1. class TestA {  2. TestB b;  3. TestA() {  4. b = new TestB(this);  5. }  6. }  7. class TestB {  8. TestA a;  9. TestB(TestA a) {  10. this.a = a;  11. }  12. }  13. class TestAll {  14. public static void main (String args[]) {  15. new TestAll().makeThings(); 16. // ...code continues on  17. }  18. void makeThings() {  19. TestA test = new TestA(); 20. }  21. }  Which two statements are true after line 15, before main completes?()

  • A、 Line 15 causes a stack overflow.
  • B、 An exception is thrown at runtime.
  • C、 The object referenced by a is eligible for garbage collection.
  • D、 The object referenced by b is eligible for garbage collection.
  • E、 The object referenced by a is not eligible for garbage collection.
  • F、 The object referenced by b is not eligible for garbage collection.

正确答案:C,D

更多相关问题