Line 15 causes a stack overflow.
An exception is thrown at runtime.
The object referenced by a is eligible for garbage collection.
The object referenced by b is eligible for garbage collection.
The object referenced by a is not eligible for garbage collection.
The object referenced by b is not eligible for garbage collection.
第1题:
A.Stringregex=“”;
B.Stringregex=““;
C.Stringregex=“.*“.
D.Stringregex=“\\s”
E.Stringregex=“\\.\\s*”;
F.Stringregex=“\\w[\.]+“;
第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
第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的时候,结果是哪项?()
第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?()
第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.
第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.运行时抛出异常
第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?()
第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?()