网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
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.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、Line5B、Line6C、Line7D、Line8E、Line9F、Line10” 相关考题
考题
有如下程序#includeusing namespace std;class Obj{static int i;public:Obj(){i++;}~Obj(){i--;}static int getVal(){teturn i;}};int Obj::i=0;void f (){Obj ob2;coutObj obl;F();Obj*ob3=new Obj;coutDelete ob3;cout}程序的输出结果是______。A.232B.231C.222D.221
考题
( 29 ) 有如下程序 :#includeusing namespace std;class Obj{static int i;public:Obj( ){ i++; }~Obj( ){ i--; }static int getVal( ){ return i;}};int Obj::i=0;void f(){Obj ob2; coutint main( ){Obj ob1;f( );Obj *ob3=new Obj; coutgetVal( );delete ob3; cout return 0;}程序的输出结果是A ) 232B ) 231C ) 222D ) 221
考题
有如下程序: include using namespace std; class Obj { static in
有如下程序: #include <iostream> using namespace std; class Obj { static int i; public: Obj( ){i++;} ~Obj(){i--;} static int getVal( ){ return i;} }; int Obj::i=0; void f() {Obj ob2; cout<<ob2.getVal( ); } int main( ){ Obj ob1; f(); Obj *ob3=ew Obj; cout<<ob3->getVal( ); delete ob3; cout<<Obj::getVal( ); return 0; } 程序的输出结果是A.232B.231C.222D.221
考题
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.Line5B.Line6C.Line7D.Line8E.Line9F.Line10
考题
使用VC6打开考生文件夹下的工程test38_1,此工程包含一个源程序文件test38_1.cpp,但该程序运行有问题,请改正函数中的错误,使该程序的输出结果为:2 is a factor of 10源程序文件test38_1.cpp清单如下:include <iostream.h>class myclass{/***************** found *****************/int n,dpublic:myclass(int i, int j){ n=i; d=j; }friend int factor( myclass ob);};/***************** found *****************/int myclass::factor(myclass ob){/***************** found *****************/if(ob.n%ob.d)return 1;elsereturn 0;}void main(){myclass ob1(10,2),ob2(13,3);if(factor(ob1))cout<<"2 is a factor of 10\n";if(factor(ob2))cout<<"3 is not a factor of 13\n";}
考题
有如下程序:include using namespace std;class Obj { static int i;public:Obj(){i+
有如下程序:#include <iostream>using namespace std;class Obj { static int i;public: Obj(){i++;} -Obj(){i--;} static int getVal(){return i;} };int Obj::i=0;void f(){Obj ob2; cout<<ob2.getVal(); }hat main(){ Obj ob1; f(); Obj *ob3=new Obj; cout<<ob3->getVal(); delete ob3; cout<<Obj:: getVal(); return (); }程序的输出结果是( )。A.232B.231C.222D.221
考题
下面程序输出的结果为#include"iostream.h"class A{public:A( ){cout<<"CLASS A"<<endl;}~A( ){}};class B:public A{public:B( ){cout<<"CLASS B"<<endl;}~B( ){}};void main( ){A*p;p=new B;B *q;q=new B;}A.CLASS A CLASS BB.CLASS A CLASS B CLASS BC.CLASS A CLASS B CLASS A CLASS BD.CLASS A CLASS B CLASS B CLASS B
考题
以下程序运行后的输出结果是______。includeinclude usingnamespacestd;classY
以下程序运行后的输出结果是______。include <iostream>include <string>using namespace std;class Y;class X{int x;char *strx;public:X(int a, char *str){x=a;strx=new char[strlen(str)+1]strcpy (strx,str);}void show(Y ob);};class Y{prlvate:int y;char *stry;public:Y(int b,char *str){y=b;stry=new char[strlen(str)+1];strcpy(stry,str);}friend void X::show(Y ob);};void X::show{Y ob){cout<<strx<<",",cout<<ob.stry<<endl;}int main{{X a (10, "stringX");Y b (20, "stringY");a. show (b);renurn 0;}
考题
使用VC6打开考生文件夹下的工程test36_1,此工程包含一个源程序文件test36_1.cpp,但该程序运行有问题,请改正函数中的错误,使该程序的输出结果为:2源程序文件test36_1.cpp清单如下:include<iostream.h>class amount;class coins{/***************** found *****************/enum units {penny, nickel, dime, quarter, half_dollar}/***************** found *****************/class amount;};class amount{/***************** found *****************/coins:units money;public:void setm();int germ();};void amount::setm(){money = coins::dime;}int amount::getm(){return money;}int main ( ){amount ob;ob.setm();cout << ob.getm()<<end1;return 0;}
考题
有如下程序: #includeiostream using namespace std; class Obj{ static int i; public: Obj{i++;} 一Obj{i一一;} static int getVal{return i;} }; int Obj::i=0: void f{Obj ob2;coutob2.getVal;} int main{ Obj obl; f; Obj}ob3=new Obj;coutob3一getVal; delete ob3;coutObj::getVal; return 0; } 执行这个程序的输出结果是( )。A.232B.231C.222D.221
考题
有以下程序:include include using namespace std;class Y;class X{private
有以下程序: #include <iostream> #include <string> using namespace std; class Y; class X { private: int x; char *strx; public: X(int a, char *str) { x=a; strx=new char[strlen(str)+1]; strcpy(strx,str); } void show(Y ob) ; }; class Y { private: int y; char *stry; public: Y(int b,char *str) { y=b; stry=new char[strlen(str)+1]; strcpy(stry, str); } friend void X: :show(Y ob) ; }; void X: :show(Y ob) { cout<<strx<<", "; cout<<ob, stry<<end1; } int main ( ) { X a(10,"X"); Y b (20, "Y"); a. show(B) ; return 0; } 执行后的输出结果是( )。A.X,YB.a,bC.X,XD.Y,Y
考题
1.public class test ( 2.public static void main (String args[]) { 3.int i = 0xFFFFFFF1; 4.int j = ~i; 5. 6.} 7.) What is the decimal value of j at line 5?() A、 0B、 1C、 14D、 –15E、 An error at line 3 causes compilation to fail.F、 An error at line 4 causes compilation to fail.
考题
1.public class Test { 2.public static void main (String args[]) { 3.class Foo { 4.public int i = 3; 5.} 6.Object o = (Object) new Foo(); 7.Foo foo = (Foo)o; 8.System.out.printIn(foo. i); 9. } 10.} What is the result?() A、 Compilation will fail.B、 Compilation will succeed and the program will print “3”C、 Compilation will succeed but the program will throw a ClassCastException at line 6.D、 Compilation will succeed but the program will throw a ClassCastException at line 7.
考题
将雌性纯合子(oB、/oB、,♀)的卵巢移植到杂合子(oB、/+,♀)体内,再用宿主与雄性杂合子(oB、/+,♂)交配,()。A、F1代为oB、/oB、的比例为50%B、F1代为oB、/oB、的比例为25%C、C、F1代为o/oB、的比例为75%D、D、F1代为o/oB、的比例为100%
考题
单选题1.public class test ( 2.public static void main (String args[]) { 3.int i = 0xFFFFFFF1; 4.int j = ~i; 5. 6.} 7.) What is the decimal value of j at line 5?()A
0B
1C
14D
–15E
An error at line 3 causes compilation to fail.F
An error at line 4 causes compilation to fail.
考题
单选题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
Line5B
Line6C
Line7D
Line8E
Line9F
Line10
考题
单选题1.public classA{ 2.public String doit(intx,inty){ 3.return"a"; 4.} 5. 6.public String doit(int...vals){ 7.return"b"; 8.} 9.} And: 25.A a=new A(); 26.System.out.println(a.doit(4,5)); What is the result?()A
Line 26 prints a to System.out.B
Line 26 prints b to System.out.C
An exception is thrown at line 26 at runtime.D
Compilation of class A will fail due to an error in line 6.
考题
单选题1.public class Test{ 2.int x=12; 3.public void method(intx){ 4.x+=x; 5.System.out.println(x); 6.} 7.} Given: 34.Test t=new Test(); 35.t.method(5); What is the output from line 5 of the Test class?()A
5B
10C
12D
17E
24
考题
单选题1.public class Test { 2.public static void main (String args[]) { 3.class Foo { 4.public int i = 3; 5.} 6.Object o = (Object) new Foo(); 7.Foo foo = (Foo)o; 8.System.out.printIn(foo. i); 9. } 10.} What is the result?()A
Compilation will fail.B
Compilation will succeed and the program will print “3”C
Compilation will succeed but the program will throw a ClassCastException at line 6.D
Compilation will succeed but the program will throw a ClassCastException at line 7.
热门标签
最新试卷