单选题11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?()A TrueB Not trueC An exception is thrown at runtime.D Compilation fails because of an error at line 12.E Compilation fails because of an error at line 19.

单选题
11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?()
A

 True

B

 Not true

C

 An exception is thrown at runtime.

D

 Compilation fails because of an error at line 12.

E

 Compilation fails because of an error at line 19.


参考解析

解析: 暂无解析

相关考题:

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

11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?() A、 TrueB、 Not trueC、 An exception is thrown at runtime.D、 Compilation fails because of an error at line 12.E、 Compilation fails because of an error at line 19.

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 static void main(String[] args) {  12. Object obj = new Object() {  13. public int hashCode() {  14. returns 42; 15. }  16. };  17. System.out.println(obj.hashCode());  18. }    What is the result? () A、 42B、 An exception is thrown at runtime.C、 Compilation fails because of an error on line 12.D、 Compilation fails because of an error on line 16.E、 Compilation fails because of an error on line 17.

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 interface Status {  12. /* insert code here */ int MY_VALUE = 10;  13. }  Which three are valid on line 12?()A、 finalB、 staticC、 nativeD、 publicE、 privateF、 abstractG、 protected

public void testIfA(){ if(testIfB("True")){ System.out.println("True"); }else{ System.out.println("Nottrue"); } } public Boolean testIfB(Stringstr){ return Boolean.valueOf(str); } What is the result when method testIfA is invoked?()A、TrueB、NottrueC、Anexceptionisthrownatruntime.D、Compilationfailsbecauseofanerroratline12.E、Compilationfailsbecauseofanerroratline19.

10. public class MyClass {  11.  12. public Integer startingI;  13. public void methodA() {  14. Integer i = new Integer(25);  15. startingI = i;  16. methodB(i);  17. }  18. private void methodB(Integer i2) {  19. i2 = i2.intValue();  20.  21. }  22. }  If methodA is invoked, which two are true at line 20?()A、 i2 == startingI returns true.B、 i2 == startingI returns false.C、 i2.equals(startingI) returns true.D、 i2.equals(startingI) returns false.

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:   11. // insert code here   12. private N min, max;   13. public N getMin() { return min; }   14. public N getMax() { return max; }   15. public void add(N added) {   16. if (min == null || added.doubleValue()  max.doubleValue())  19. max = added;   20. }   21. }   Which two, inserted at line 11, will allow the code to compile?()AABBCCDDEEFF

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

单选题10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  Which code, inserted at line 15, allows the class Sprite to compile?()A Foo { public int bar() { return 1; } }B new Foo { public int bar() { return 1; } }C newFoo() { public int bar(){return 1; } }D new class Foo { public int bar() { return 1; } }

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

单选题public void testIfA(){ if(testIfB("True")){ System.out.println("True"); }else{ System.out.println("Nottrue"); } } public Boolean testIfB(Stringstr){ return Boolean.valueOf(str); } What is the result when method testIfA is invoked?()ATrueBNottrueCAnexceptionisthrownatruntime.DCompilationfailsbecauseofanerroratline12.ECompilationfailsbecauseofanerroratline19.

单选题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. class Converter {  12. public static void main(String[] args) {  13. Integer i = args[0];  14. int j = 12;  15. System.out.println(”It is “ + (j==i) + “that j==i.”);  16. }  17. }  What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?()A It is true that j==i.B It is false that j==i.C An exception is thrown at runtime.D Compilation fails because of an error in line 13.

多选题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 void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?()A TrueB Not trueC An exception is thrown at runtime.D Compilation fails because of an error at line 12.E Compilation fails because of an error at line 19.

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

多选题10. public class MyClass {  11.  12. public Integer startingI;  13. public void methodA() {  14. Integer i = new Integer(25);  15. startingI = i;  16. methodB(i);  17. }  18. private void methodB(Integer i2) {  19. i2 = i2.intValue();  20.  21. }  22. }  If methodA is invoked, which two are true at line 20?()Ai2 == startingI returns true.Bi2 == startingI returns false.Ci2.equals(startingI) returns true.Di2.equals(startingI) returns false.

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