1.public class GC{2.private Objec to;3.private void doSomethingElse(Object obj){o=obj;}4.public void doSomething(){5.Object o=new Object();6.doSomethingElse(o);7.o=new Object();8.doSomethingElse(null);9.o=null;10.}11.}When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()
A.Line5
B.Line6
C.Line7
D.Line8
E.Line9
F.Line10
第1题:
设有以下定义和程序: #include <iostream.h> class A1 { public: void showl() { cout<<"class A1"<<end1; } }; Class A2 : public A1 { public: void show2() { cout<<"Class A2"<<end1; } }; Class A3 : protected A2 { public: void show3() { cout<<”Class A土”<<end1; } }; void main() { A1 obj1; A2 obj2; A3 obj3; } 则以下不合语法的调用语句是( )。
A.obj1.show1();
B.obj2.show1();
C.obj3.show1();
D.obj2.show2();
第2题:
对于下列程序段,没有二义性的表达式是() class A {public: int f(); }; class B {public: int g(); int f(); }; class C:public A,public B {public : int g(); h(); }; C obj;
A.obj.f()
B.obj.A::g()
C.obj.B::f()
D.obj.B::h()
第3题:
type(obj) 函数为返回参数obj的类型,eval(obj)函数负责将obj两侧的一对单/双引号去除,则type(eval('"45"'))的结果为
A.45
B.<class 'int'>
C.<class 'str'>
D.None
第4题:
下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
include<iostream.h>
class A
{
private:
int numl;
public:
A( ):numl(0){}
A(int i):numl(i){}
};
class B
{
private:
int num2;
public:
B( ):num2(0){}
B(int i):num2(i){}
int my_math(A obj1, B obj2);
};
int B::my_math(A obj1,B obj2)
{
return(obj1.numl+obj2.num2);
}
void main(void)
{
A objl(4);
B obj,obj2(5);
cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);
}
第5题:
3、对于下列程序段,没有二义性的表达式是() class A {public: int f(); }; class B {public: int g(); int f(); }; class C:public A,public B {public : int g(); h(); }; C obj;
A.obj.f()
B.obj.A::g()
C.obj.B::f()
D.obj.B::h()