网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

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

考题 函数ROUND(12. 15,1)的计算结果为()。A 12. 2B 10C 12D 12. 25

考题 10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?() A、 StackOverflowErrorB、 NullPointerExceptionC、 NumberFormatExceptionD、 IllegalArgumentExceptionE、 ExceptionlnlnitializerError

考题 11.public class Counter{ 12.public static void main(String[]args){ 13.int numArgs=/*insert code here*/; 14.} 15.} and the command line:java Counter one fred 42 Which code,inserted at line 13,captures the number of arguments passed into the program?()A、args.countB、args.lengthC、args.count()D、args.length()E、args.getLength()

考题 11. public void addStrings(List list) {  12. list.add(”foo”);  13. list.add(”bar”);  14. }  What must you change in this method to compile without warnings?() A、 add this code after line 11: list = (List) list;B、 change lines 12 and 13 to: list.add(”foo”); list.add(”bar”);C、 change the method signature on line 11 to: public void addStrings(List extends String list) {D、 change the method signature on line 11 to: public void addStrings(List super String list) {E、 No changes are necessary. This method compiles without warnings.

考题 现有:  1.  class Propeller2  {  2.   pulolic static void main (String[]args)//add code here?      3.    {  new Propeller2().topGo();  }      4.  5.void topGo()  //add code here?      6.    {   middleGo();  }      7.  8.void middleGo()  //add code here?  9. {   go();  System.out.println ("late middle");  }    void go()  //add code here?      12.    {throw new Exception();  }      13.  }  为使代码通过编译,需要在哪一行加入声明throws Exception?()     A、只在第11行B、在第8行和第11行C、在第5行、第8行和第11行D、在第2行、第5行、第8行和第11行

考题 11.public class Commander{ 12.public static void main(String[]args){ 13.String myProp=/*insert code here*/ 14.System.out.println(myProp); 15.} 16.} and the command line: java-Dprop.custom=gobstopper Commander Which two,placed on line13,will produce the output gobstopper?()A、System.load("prop.custom");B、System.getenv("prop.custom");C、System.property("prop.custom");D、System.getProperty("prop.custom");E、System.getProperties().getProperty("prop.custom");

考题 11. static class A {  12. void process() throws Exception { throw new Exception(); }  13. }  14. static class B extends A {  15. void process() { System.out.println(”B”); }  16. }  17. public static void main(String[] args) {  18. new B().process();  19. }  What is the result?() A、 BB、 The code runs with no output.C、 Compilation fails because of an error in line 12.D、 Compilation fails because of an error in line 15.E、 Compilation fails because of an error in line 18.

考题 11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()  A、 Line 13B、 Line 14C、 Line 18D、 Line 20

考题 11. public static void append(List list) { list.add(”0042”); }  12. public static void main(String[] args) {  13. List intList = new ArrayList();  14. append(intList);  15. System.out.println(intList.get(0));  16. }  What is the result?() A、 42B、 0042C、 An exception is thrown at runtime.D、 Compilation fails because of an error in line 13.E、 Compilation fails because of an error in line 14.

考题 Given:   10. class One {   11. void foo() { }   12. }   13. class Two extends One {   14. //insert method here   15. }   Which three methods, inserted individually at line 14, will correctly complete class Two?()A、 public void foo() { /* more code here */ }B、 private void foo() { /* more code here */ }C、 protected void foo() { /* more code here */ }D、 int foo() { /* more code here */ }  E、 void foo() { /* more code here */ }

考题 单选题11. public static void append(List list) { list.add(”0042”); }  12. public static void main(String[] args) {  13. List intList = new ArrayList();  14. append(intList);  15. System.out.println(intList.get(0));  16. }  What is the result?()A  42B  0042C  An exception is thrown at runtime.D  Compilation fails because of an error in line 13.E  Compilation fails because of an error in line 14.

考题 多选题Given:   10. class One {   11. void foo() { }   12. }   13. class Two extends One {   14. //insert method here   15. }   Which three methods, inserted individually at line 14, will correctly complete class Two?()Apublic void foo() { /* more code here */ }Bprivate void foo() { /* more code here */ }Cprotected void foo() { /* more code here */ }Dint foo() { /* more code here */ }Evoid foo() { /* more code here */ }

考题 单选题Given: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.// insert code here 16.} 17.} and this element in the web application’s deployment descriptor: 302 /html/error.html Which,inserted at line 15,causes the container to redirect control to the error.html resource?()A response.setError(302);B response.sendError(302);C response.setStatus(302);D response.sendRedirect(302);E response.sendErrorRedirect(302);

考题 单选题11. static class A {  12. void process() throws Exception { throw new Exception(); }  13. }  14. static class B extends A {  15. void process() { System.out.println(”B”); }  16. }  17. public static void main(String[] args) {  18. new B().process();  19. }  What is the result?()A  BB  The code runs with no output.C  Compilation fails because of an error in line 12.D  Compilation fails because of an error in line 15.E  Compilation fails because of an error in line 18.

考题 单选题11.classA {  12. public void process() { System.out.print(”A “); } }  13. class B extends A {  14. public void process() throws RuntimeException {  15. super.process();  16. if (true) throw new RuntimeException();  17. System.out.print(“B”); }}  18. public static void main(String[] args) {  19. try { ((A)new B()).process(); }  20. catch (Exception e) { System.out.print(”Exception “); }  21. }  What is the result?()A  ExceptionB  A ExceptionC  A Exception BD  A B ExceptionE  Compilation fails because of an error in line 14.F  Compilation fails because of an error in line 19.

考题 单选题1. public class SimpleCalc {  2. public int value;  3. public void calculate() { value += 7; }  4. } And:  1. public class MultiCalc extends SimpleCalc {  2. public void calculate() { value -= 3; }  3. public void calculate(int multiplier) {  4. calculate();  5. super.calculate();  6. value *=multiplier;  7. }  8. public static void main(String[] args) {  9. MultiCalc calculator = new MultiCalc();  10. calculator.calculate(2);  11. System.out.println(”Value is: “+ calculator.value);  12. }  13. }  What is the result?()A  Value is: 8B  Compilation fails.C  Value is: 12D  Value is: -12E  The code runs with no output.F  An exception is thrown at runtime.

考题 单选题11.public class Counter{ 12.public static void main(String[]args){ 13.int numArgs=/*insert code here*/; 14.} 15.} and the command line:java Counter one fred 42 Which code,inserted at line 13,captures the number of arguments passed into the program?()A args.countB args.lengthC args.count()D args.length()E args.getLength()

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

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

考题 单选题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?()A 123B Compilation fails because of an error in line 12.C Compilation fails because of an error in line 13.D Compilation fails because of an error in line 14.E A ClassCastException is thrown at runtime.

考题 单选题10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?()A  StackOverflowErrorB  NullPointerExceptionC  NumberFormatExceptionD  IllegalArgumentExceptionE  ExceptionlnlnitializerError

考题 单选题Given:   11. public static void main(String[] args) {   12. Object obj = new int[] { 1, 2, 3 };   13. int[] someArray = (int[])obj;   14. for (int i : someArray) System.out.print(i + " ");   15. }   What is the result? ()A  Compilation fails because of an error in line 13.B  A ClassCastException is thrown at runtime.C  1 2 3D  Compilation fails because of an error in line 14.E  Compilation fails because of an error in line 12.

考题 多选题10. class Foo {  11. static void alpha() { /* more code here */ }  12. void beta() { /* more code here */ }  13. }  Which two are true?()AFoo.beta() is a valid invocation of beta().BFoo.alpha() is a valid invocation of alpha().CMethod beta() can directly call method alpha().DMethod alpha() can directly call method beta().

考题 单选题11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()A  Line 13B  Line 14C  Line 18D  Line 20

考题 单选题1. class Pizza {  2. java.util.ArrayList toppings;  3. public final void addTopping(String topping) {  4. toppings.add(topping); 5. }  6. }  7. public class PepperoniPizza extends Pizza {  8. public void addTopping(String topping) {  9. System.out.println(”Cannot add Toppings”);  10. }  11. public static void main(String[] args) {  12. Pizza pizza = new PepperoniPizza();  13. pizza.addTopping(”Mushrooms”);  14. }  15. }  What is the result?()A  Compilation fails.B  Cannot add ToppingsC  The code runs with no output.D  A NullPointerException is thrown in Line 4.

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