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.
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
下列代码的执行结果是______。int numbers[]=new int[6];for(int i=1;i<numbers.length;i++){numbers[i]=i-1;System.out.print(numbers[i]+"");}A) 0 1 2 3 4 5B) 1 2 3 4 5 6C) 0 1 2 3 4D) 1 2 3 4 5A.B.C.D.
在程序中,用户使用JOptionPane输入一个二维数组的行数,程序随机生成每一行的列数,并对其赋值。最后显示这个二维数组。请填写横线处的内容。注意:请勿修改main()主方法和其他已有语句内容,仅在横线处填入适当语句。import javax.swing.*;public class basic{public static void main(String[] args){String sDimU=JOptionPane.showInputDialog("请输入数组的行数");int iDimU=______(sDimU);int [].[] numbers=new int[iDimU] [];for(int i=0; i<iDimU; i++){int k=(int) (Math.random()*5+1);numbers[i]=______;}for(int i=0; i<iDimU; i++){for(int j=0;______; j++){numbers[i] [j]=(int) (Math.random()*l00);System.out.print(numbers[i] [j]+" ");}System.out.println ();}System.exit(O)}}
为使下列代码正常运行,应该在下画线处填入的选 项是( )。 int[]numbers=new int[n]; for(int i=0;inumbers. ;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.
11.publicvoidgenNumbers(){12.ArrayListnumbers=newArrayList();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.}WhichlineofcodemarkstheearliestpointthatanobjectreferencedbyintObjbecomesacandidateforgarbagecollection?()A.Line16B.Line17C.Line18D.Line19E.TheobjectisNOTacandidateforgarbagecollection.
Given:11.publicvoidgenNumbers(){12.ArrayListnumbers=newArrayList();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.}WhichlineofcodemarkstheearliestpointthatanobjectreferencedbyintObjbecomesacandidateforgarbagecollection?()A.Line19B.TheobjectisNOTacandidateforgarbagecollection.C.Line17D.Line16E.Line18
为使下列代码正常运行,应该在下画线处填入的选项是( )。 int[]numbers=new int[n]; for(int i=0;inumbers. ;i++) numbers[i]=i+1:A.sizeB.lengthC.dimensionD.measurement
若有以下程序: void g(int **q) { (**q) ++; (*q) ++; } void main() { int line [5]; int *p=line; for (i=0; i<5; i++) { *p=i; g(P); } for (i=0; i<5; i++) cout<<line[i]; cout<<end1; } 该程序运行后的输出结果为( )。A.12345B.1234C.11111D.55555
ArraryList a = new ArrayList(); a.add(“Alpha”); a.add(“Bravo”): a.add(“Charlie”); a.add(“Delta”); Iterator iter = a.iterator(); Which two, added at line 17, print the names in the ArrayList in alphabetical order?()A、 for (int i=0; i a.size(); i++) System.out.println(a.get(i)));B、 for (int i=0; i a.size(); i++) System.out.println(a[i]);C、 while( iter.hasNext() ) System.out.println(iter.next()) ;D、 for (int i=0, i a.size(); i++) System.out.println(iter[i]);E、 for (int i=0; i a.size(); i++) System.out.println(iter.get(i));
You need to create a JSP that generates some JavaScript code to populate an array of strings used on theclient-side. Which JSP code snippet will create this array?()A、MY_ARRAY = new Array();% for ( int i = 0; i serverArray.length; i++ ) { MY_ARRAY[%= i %] = ’%= serverArray[i] %’;} %B、MY_ARRAY = new Array();. % for ( int i = 0; i serverArray.length; i++ ) { . MY_ARRAY[${i}] = ’${serverArray[i]}’;. } %C、MY_ARRAY = new Array();. % for ( int i = 0; i serverArray.length; i++ ) { % . MY_ARRAY[%= i %] = ’%= serverArray[i] %’;. % } %D、MY_ARRAY = new Array();% for ( int i = 0; i serverArray.length; i++ ) { % . MY_ARRAY[${i}] = ’${serverArray[i]}’;. % } %
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 16B、 Line 17C、 Line 18D、 Line 19E、 The object is NOT a candidate for garbage collection.
Given the following code: 1) public void modify() { 2) int i, j, k; 3) i = 100; 4) while ( i 0 ) { 5) j = i * 2; 6) System.out.println (" The value of j is " + j ); 7) k = k + 1; 8) i--; 9) } 10) } Which line might cause an error during compilation?() A、 line 4B、 line 6C、 line 7D、 line 8
public class TestOne implements Runnable { public static void main (String[] args) throws Exception { Thread t = new Thread(new TestOne()); t.start(); System.out.print(”Started”); t.join(); System.out.print(”Complete”); } public void run() { for (int i= 0; i 4; i++) { System.out.print(i); } } } What can be a result?()A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes and prints “StartedComplete”.D、 The code executes and prints “StartedComplete0123”.E、 The code executes and prints “Started0l23Complete”.
1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call? () A、 on line 2B、 on line 3C、 on line 6D、 on line 7
import java.util.*; public class NameList { private List names = new ArrayList(); public synchronized void add(String name) { names.add(name); } public synchronized void printAll() { for (int i = 0; i System.out.print(names.get(i) +“ “); } } public static void main(String[] args) { final NameList sl = new NameList(); for(int i=0;i2;i++) { new Thread() { public void ruin() { sl.add(”A”); sl.add(”B”); sl.add(”C”); sl.printAll(); } }.start(); } } } Which two statements are true if this class is compiled and run?() A、 An exception may be thrown at runtime.B、 The code may run with no output, without exiting.C、The code may rum with output “A B A B C C “, then exit.D、The code may ruin with output “A A A B C A B C C “, then exit.E、 The code may rum with output “A B C A B C A B C “, then exit.F、The code may ruin with output “A B C A A B C A B C “, then exit.
Given the following code: public class Test { void printValue(int m){ do { System.out.println("The value is"+m); } while( --m 10 ) } public static void main(String arg[]) { int i=10; Test t= new Test(); t.printValue(i); } } Which will be output?() A、 The value is 8B、 The value is 9C、 The value is 10D、 The value is 11
Consider the following class: class Test(int i) { void test(int i) { System.out.println(“I am an int.”); } void test(String s) { System.out.println(“I am a string.”); } public static void main(String args) { Test t=new Test(); char ch=“y”; t.test(ch); } } Which of the statements below is true?()A、 Line 5 will not compile, because void methods cannot be overridden.B、 Line 12 will not compile, because there is no version of test() that rakes a charargument.C、 The code will compile but will throw an exception at line 12.D、 The code will compile and produce the following output: I am an int.E、 The code will compile and produce the following output: I am a String.
public class TestFive { private int x; public void foo() { int current = x; x = current + 1; } public void go() { for(int i=0;i5;i++) { new Thread() { public void run() { foo(); System.out.print(x + “, “); } }.start(); }}} Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?()A、 Move the line 12 print statement into the foo() method.B、 Change line 7 to public synchronized void go() {.C、 Change the variable declaration on line 3 to private volatile int x;.D、 Wrap the code inside the foo() method with a synchronized( this ) block.E、 Wrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }.
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?()A、public void DoWork();B、public void DoWork(int nCounter);C、public void DoWork(object oCounter);D、public void DoWork(Delegate oCounter);
多选题1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call?()Aon line 2Bon line 3Con line 6Don line 7
多选题Given 11.public interface Status { 12./* insert code here */ int MY_VALUE = 10; 13.} Which three are valid on line 12?()AfinalBstaticCnativeDpublicEprivate
多选题ArraryList a = new ArrayList(); a.add(“Alpha”); a.add(“Bravo”): a.add(“Charlie”); a.add(“Delta”); Iterator iter = a.iterator(); Which two, added at line 17, print the names in the ArrayList in alphabetical order?()Afor (int i=0; i a.size(); i++) System.out.println(a.get(i)));Bfor (int i=0; i a.size(); i++) System.out.println(a[i]);Cwhile( iter.hasNext() ) System.out.println(iter.next()) ;Dfor (int i=0, i a.size(); i++) System.out.println(iter[i]);Efor (int i=0; i a.size(); i++) System.out.println(iter.get(i));
单选题为使下列代码正常运行,应该在下画线处填入的选项是( )。int[] numbers=new int[n];for (int i=0; i<numbers. ______;i++)numbers[i]=i+1;AsizeBlengthCdimensionDmeasurement
单选题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.
单选题下列代码的执行结果是( )。int numbers[] = new int[6];for(int i=1;i numbers[i] =i-1;System.out.print(numbers[i]+" ");}A0 1 2 3 4 5B1 2 3 4 5 6C-1 0 1 2 3 4 D0 1 2 3 4
单选题Given the following code: public class Test { void printValue(int m){ do { System.out.println("The value is"+m); } while( --m 10 ) } public static void main(String arg[]) { int i=10; Test t= new Test(); t.printValue(i); } } Which will be output?()A The value is 8B The value is 9C The value is 10D The value is 11