单选题11.public void genNumbers(){ 12.ArrayList numbers=new ArrayList(); 13.for(inti=0;i10;i++){ 14.intvalue=i*((int)Math.random()); 15.IntegerintObj=newInteger(value); 16.numbers.add(intObj); 17.} 18.System.out.println(numbers); 19.} Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbagec ollection?()ALine16BLine17CLine18DLine19EThe object is NOT a candidate for garbage collection.
单选题
11.public void genNumbers(){ 12.ArrayList numbers=new ArrayList(); 13.for(inti=0;i<10;i++){ 14.intvalue=i*((int)Math.random()); 15.IntegerintObj=newInteger(value); 16.numbers.add(intObj); 17.} 18.System.out.println(numbers); 19.} Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbagec ollection?()
A
Line16
B
Line17
C
Line18
D
Line19
E
The object is NOT a candidate for garbage collection.
参考解析
解析:
暂无解析
相关考题:
为使下列代码正常运行,应该在下划线处填入的选项是int〔〕numbers=new int[n];for(Int i=0;i numbers.____;i++)numbers[i]=i+1;A.sizeB.lengthC.dimensionD.measurement
11.public void genNumbers(){12.ArrayList numbers=new ArrayList();13.for(inti=0;i14.intvalue=i*((int)Math.random());15.IntegerintObj=newInteger(value);16.numbers.add(intObj);17.}18.System.out.println(numbers);19.}Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbagec ollection?()A.Line16B.Line17C.Line18D.Line19E.The object is NOT a candidate for garbage collection.
下面程序的运算结果是()。includeusing namespace std;class A{public:virtual void f 下面程序的运算结果是( )。 #include<iostream> using namespace std; class A { public: virtual void fun()=0; }; class B:public A } public: void fun() {cout<<"new file"<<" ";} }; class C:public A { public: void fun() { cout<<"open file"<<" ";} }; void main() { A a, * p; B b;C c; p=c; p->fun(); p=b; }A.new file open fileB.new file new fileC.编译出错D.open file new file
写出程序的输出结果:public class A{public virtual void Fun1(int i){Console.WriteLine(i);}public void Fun2(A a){a.Fun1(1);Fun1(5);}}public class B : A{public override void Fun1(int i){base.Fun1 (i + 1);}public static void Main(){B b = new B();A a = new A();a.Fun2(b);b.Fun2(a);}}
请写出下面的输出:class B{public:virtual void Print(void){printf(“B::Print\n”);}virtual void Reprint(void){printf(“B:Reprint\n”);}void Algo(void){Print();Reprint();}};class D : public B{public:virtual void Print(void){printf(“D::Print\n”);}};void main(){B *p = new D();p-Print();p-Algo();}
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是A.Test t=new Test();B.Thread t=new Thread();C.Thread t=new Thread(new Test());D.Test t=new Thread();
下面程序的结果是 ______。includeclass A{ public:virtual voidfun()=0{};};class 下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=c; p->fun (); p=b; p->fun (); p=d; p->fun(); }A.new file open file save fileB.new file new file new fileC.编译出错D.open file new file save file
class One { public One() { System.out.print(1); } } class Two extends One { public Two() { System.out.print(2); } } class Three extends Two { public Three() { System.out.print(3); } } public class Numbers{ public static void main( String[] argv) { new Three(); } } What is the result when this code is executed?() A、 1B、 3C、 123D、 321E、 The code rims with no output.
11.public void genNumbers(){ 12.ArrayList numbers=new ArrayList(); 13.for(inti=0;i10;i++){ 14.intvalue=i*((int)Math.random()); 15.IntegerintObj=newInteger(value); 16.numbers.add(intObj); 17.} 18.System.out.println(numbers); 19.} Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbagec ollection?()A、Line16B、Line17C、Line18D、Line19E、The object is NOT a candidate for garbage collection.
class MyThread extends Thread { public void run() { System.out.println(“AAA”); } public void run(Runnable r) { System.out.println(“BBB”); } public static void main(String[] args) { new Thread(new MyThread()).start(); } } What is the result?() A、 AAAB、 BBBC、 Compilation fails.D、 The code runs with no output.
interface Animal { void soundOff(); } class Elephant implements Animal { public void soundOff() { System.out.println(“Trumpet”); } } class Lion implements Animal { public void soundOff() { System.out.println(“Roar”); } } class Alpha1 { static Animal get( String choice ) { if ( choice.equalsIgnoreCase( “meat eater” )) { return new Lion(); } else { return new Elephant(); } } } Which compiles?() A、 new Animal().soundOff();B、 Elephant e = new Alpha1();C、 Lion 1 = Alpha.get(“meat eater”);D、 new Alpha1().get(“veggie”).soundOff();
Which two code fragments will execute the method doStuff() in a separate thread?()A、 new Thread() { public void run() { doStuff(); } }B、 new Thread() { public void start() { doStuff(); } }C、 new Thread() { public void start() { doStuff(); } } .run();D、 new Thread() { public void run() { doStuff(); } } .start();E、 new Thread(new Runnable() { public void run() { doStuff(); } } ).run();F、 new Thread(new Runnable() { public void run() { doStuff(); } }).start();
public class Threads4 { public static void main (String[] args) { new Threads4().go(); } public void go() { Runnable r = new Runnable() { public void run() { System.out.print(”foo”); } }; Thread t = new Thread(r); t.start(); t.start(); } } What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints „foo”.D、 The code executes normally, but nothing is printed.
Which two code fragments will execute the method doStuff() in a separate thread?()A、new Thread() {public void run() { doStuff(); }};B、new Thread() {public void start() { doStuff(); }};C、new Thread() {public void start() { doStuff(); }}.run();D、new Thread() {public void run() { doStuff(); }}.start();E、new Thread(new Runnable() {public void run() { doStuff(); }}).start();
单选题1)#include 2)# include 3)using namespace std; 4)double max(double x,doubley); 5)void main() 6){ 7)double a,b,c; 8)cout ab; 10)c=max(a,b); 11)couty) 16)returnx; 17)else 18)returny; 19)}执行完第8行后,屏幕上输出:()Ainput two numbers:/nBinput two numbers:Ccout”input two numbers:/n”D”please input two numbers:/n”
单选题Which method implementations will write the given string to a file named "file", using UTF8 encoding?() IMPLEMENTATION a: public void write(String msg) throws IOException { FileWriter fw = new FileWriter(new File("file")); fw.write(msg); fw.close(); } IMPLEMENTATION b: public void write(String msg) throws IOException { OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("file"), "UTF8"); osw.write(msg); osw.close(); } IMPLEMENTATION c: public void write(String msg) throws IOException { FileWriter fw = new FileWriter(new File("file")); fw.setEncoding("UTF8"); fw.write(msg); fw.close(); } IMPLEMENTATION d: public void write(String msg) throws IOException { FilterWriter fw = FilterWriter(new FileWriter("file"), "UTF8"); fw.write(msg); fw.close(); } IMPLEMENTATION e: public void write(String msg) throws IOException { OutputStreamWriter osw = new OutputStreamWriter( new OutputStream(new File("file")), "UTF8" ); osw.write(msg); osw.close(); }AImplementation a.BImplementation b.CImplementation c.DImplementation d.EImplementation e.
单选题Given that a static method doIt() in a class Work represents work to be done, what block of code will succeed in starting a new thread that will do the work? CODE BLOCK a: Runnable r = new Runnable() { public void run() { Work.doIt(); } }; Thread t = new Thread(r); t.start(); CODE BLOCK b: Thread t = new Thread() { public void start() { Work.doIt(); } }; t.start(); CODE BLOCK c: Runnable r = new Runnable() { public void run() { Work.doIt(); } }; r.start(); CODE BLOCK d: Thread t = new Thread(new Work()); t.start(); CODE BLOCK e: Runnable t = new Runnable() { public void run() { Work.doIt(); } }; t.run();ACode block a.BCode block B.CCode block c.DCode block d.ECode block e.
单选题Given: 11. public void genNumbers() { 12. ArrayList numbers = new ArrayList(); 13. for (int i=0; i10; i++) { 14. int value = i * ((int) Math.random()); 15. Integer intObj = new Integer(value); 16. numbers.add(intObj); 17. } 18. System.out.println(numbers); 19. } Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()A Line 19B The object is NOT a candidate for garbage collection.C Line 17D Line 16E Line 18
单选题class Bird { static void talk() { System.out.print("chirp "); } } class Parrot extends Bird { static void talk() { System.out.print("hello "); } public static void main(String [] args) { Bird [] birds = {new Bird(), new Parrot()}; for( Bird b : birds) b.talk(); } } 结果为:()Achirp chirpBchirp helloChello helloD编译失败
单选题public class Threads4 { public static void main (String[] args) { new Threads4().go(); } public void go() { Runnable r = new Runnable() { public void run() { System.out.print(”foo”); } }; Thread t = new Thread(r); t.start(); t.start(); } } What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes normally and prints „foo”.D The code executes normally, but nothing is printed.
多选题abstract class A { abstract void al(); void a2() { } } class B extends A { void a1() { } void a2() { } } class C extends B { void c1() { } } and: A x = new B(); C y = new C(); A z = new C(); Which four are valid examples of polymorphic method calls?()Ax.a2();Bz.a2();Cz.c1();Dz.a1();Ey.c1();Fx.a1();
单选题11.public static void main(String[]args){ 12.Object obj=new int[]{1,2,3}; 13.int[] someArray=(int[])obj; 14.for(inti:someArray)System.out.print(i+"") 15.} What is the result?()A123BCompilation fails because of an error in line 12.CCompilation fails because of an error in line 13.DCompilation fails because of an error in line 14.EA ClassCastException is thrown at runtime.
单选题You are creating a Windows Forms application by using the .NET Framework 3.5. The application requires a thread that accepts a single integer parameter. You write the following code segment (Line numbers are included for reference only.) Thread myThread = new Thread(new ParameterizedThreadStart(DoWork)) ; myThread.Start(100); You need to declare the method signature of the DoWork method. Which method signature should you use?()Apublic void DoWork();Bpublic void DoWork(int nCounter);Cpublic void DoWork(object oCounter);Dpublic void DoWork(Delegate oCounter);
多选题Which two code fragments will execute the method doStuff() in a separate thread?()Anew Thread() { public void run() { doStuff(); } }Bnew Thread() { public void start() { doStuff(); } }Cnew Thread() { public void start() { doStuff(); } } .run();Dnew Thread() { public void run() { doStuff(); } } .start();Enew Thread(new Runnable() { public void run() { doStuff(); } } ).run();Fnew Thread(new Runnable() { public void run() { doStuff(); } }).start();
单选题为使下列代码正常运行,应该在下画线处填入的选项是( )。int[] numbers=new int[n];for (int i=0; i<numbers. ______;i++)numbers[i]=i+1;AsizeBlengthCdimensionDmeasurement
单选题interface Animal { void soundOff(); } class Elephant implements Animal { public void soundOff() { System.out.println(“Trumpet”); } } class Lion implements Animal { public void soundOff() { System.out.println(“Roar”); } } class Alpha1 { static Animal get( String choice ) { if ( choice.equalsIgnoreCase( “meat eater” )) { return new Lion(); } else { return new Elephant(); } } } Which compiles?()A new Animal().soundOff();B Elephant e = new Alpha1();C Lion 1 = Alpha.get(“meat eater”);D new Alpha1().get(“veggie”).soundOff();
单选题class MyThread extends Thread { public void run() { System.out.println(“AAA”); } public void run(Runnable r) { System.out.println(“BBB”); } public static void main(String[] args) { new Thread(new MyThread()).start(); } } What is the result?()A AAAB BBBC Compilation fails.D The code runs with no output.
单选题11.public void genNumbers(){ 12.ArrayList numbers=new ArrayList(); 13.for(inti=0;i10;i++){ 14.intvalue=i*((int)Math.random()); 15.IntegerintObj=newInteger(value); 16.numbers.add(intObj); 17.} 18.System.out.println(numbers); 19.} Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbagec ollection?()ALine16BLine17CLine18DLine19EThe object is NOT a candidate for garbage collection.