单选题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 mar

题目
单选题
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.


相似考题
更多“单选题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 mark”相关问题
  • 第1题:

    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.Line16

    B.Line17

    C.Line18

    D.Line19

    E.The object is NOT a candidate for garbage collection.


    参考答案:D

  • 第2题:

    Given:11.publicvoidgenNumbers(){12.ArrayListnumbers=newArrayList();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.}WhichlineofcodemarkstheearliestpointthatanobjectreferencedbyintObjbecomesacandidateforgarbagecollection?()

    A.Line19

    B.TheobjectisNOTacandidateforgarbagecollection.

    C.Line17

    D.Line16

    E.Line18


    参考答案:A

  • 第3题:

    若有以下程序: 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.12345

    B.1234

    C.11111

    D.55555


    正确答案:A
    解析:本题考核指针的运用。主函数的for循环中向函数g()传入实参&p,则在函数g()中执行“(**q)++;”相当于执行“(**(&p))++”,即(*p)++,其结果就是对相应的数组元素值加1。函数g()中执行“(*q)++;”相当于执行“(*(&p))++”,即p++。其结果为指针p指向下一个数组元素。这样通过for循环给数组元素分别赋值1、2、3、4、5。

  • 第4题:

    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));

    正确答案:A,C

  • 第5题:

    11. public void genNumbers() {  12. ArrayList numbers = new ArrayList();  13. for (int i=0; i<10; 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 16
    • B、 Line 17
    • C、 Line 18
    • D、 Line 19
    • E、 The object is NOT a candidate for garbage collection.

    正确答案:D

  • 第6题:

    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;i<2;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.

    正确答案:E,F

  • 第7题:

    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.

    正确答案:D

  • 第8题:

    单选题
    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]}’;. <% } %>


    正确答案: D
    解析: 暂无解析

  • 第9题:

    多选题
    Given 11.public interface Status { 12./* insert code here */ int MY_VALUE = 10; 13.} Which three are valid on line 12?()
    A

    final

    B

    static

    C

    native

    D

    public

    E

    private


    正确答案: B,C
    解析: 暂无解析

  • 第10题:

    多选题
    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));


    正确答案: A,D
    解析: 暂无解析

  • 第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.


    正确答案: D
    解析: 在第12行,16位长的char型变量ch在编译时会自动转化为一个32位长的int型,并在运行时传给void test(int i)方法。

  • 第12题:

    单选题
    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 8

    B

     The value is 9

    C

     The value is 10

    D

     The value is 11


    正确答案: B
    解析: 此题考察的是do… while循环和 -- 操作符的知识,do…while最少被执行一次,在执行完do中的内容后判断while中的条件是否为true,如果为true的话就再执行do中的内容,然后再进行判断,以此类推直到while的判断为false时退出循环执行循环后面的内容,而—操作符的规则是在变量右边的-- 将先进行运算,然后才是使变量的值减一,而在变量左边的是先将变量的值减一再运算。

  • 第13题:

    11.publicvoidgenNumbers(){12.ArrayListnumbers=newArrayList();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.}WhichlineofcodemarkstheearliestpointthatanobjectreferencedbyintObjbecomesacandidateforgarbagecollection?()

    A.Line16

    B.Line17

    C.Line18

    D.Line19

    E.TheobjectisNOTacandidateforgarbagecollection.


    参考答案:D

  • 第14题:

    为使下列代码正常运行,应该在下画线处填入的选项是( )。 int[]numbers=new int[n]; for(int i=0;i<numbers. ;i++) numbers[i]=i+1:

    A.size

    B.length

    C.dimension

    D.measurement


    正确答案:B
    B。【解析】length表示数组的长度。

  • 第15题:

    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.

    正确答案:D

  • 第16题:

    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]}’;. <% } %>

    正确答案:C

  • 第17题:

    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 4
    • B、 line 6
    • C、 line 7
    • D、 line 8

    正确答案:C

  • 第18题:

    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 8
    • B、 The value is 9
    • C、 The value is 10
    • D、 The value is 11

    正确答案:C

  • 第19题:

    public class TestFive {  private int x;  public void foo() {  int current = x;  x = current + 1;  }  public void go() {  for(int i=0;i<5;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 }.

    正确答案:A,D

  • 第20题:

    单选题
    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);


    正确答案: D
    解析: 暂无解析

  • 第21题:

    单选题
    Given:   11. public void genNumbers() {   12. ArrayList numbers = new ArrayList();   13. for (int i=0; i<10; 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 19

    B

     The object is NOT a candidate for garbage collection.

    C

     Line 17

    D

     Line 16

    E

     Line 18


    正确答案: C
    解析: 暂无解析

  • 第22题:

    单选题
    为使下列代码正常运行,应该在下画线处填入的选项是(  )。 int[] numbers=new int[n]; for (int i=0; i<numbers. ______;i++) numbers[i]=i+1;
    A

    size

    B

    length

    C

    dimension

    D

    measurement


    正确答案: D
    解析:
    根据题意,程序若正常运行,i的值必须小于或等于数组的长度,length表示数组的长度,size表示泛型集合中的元素个数。

  • 第23题:

    单选题
    下列代码的执行结果是(  )。int numbers[] = new int[6];for(int i=1;i numbers[i] =i-1;System.out.print(numbers[i]+" ");}
    A

    0 1 2 3 4 5

    B

    1 2 3 4 5 6

    C

    -1 0 1 2 3 4

    D

    0 1 2 3 4


    正确答案: D
    解析:
    上述代码循环对数组numbers中的每一个成员赋值,numbers.1enght=6,循环变量i的范围是1~5,每一个成员的值为i-1,并输出该成员值,因此结果是 0 1 2 3 4 。