11. public static&ens

题目

11. public static void test(String str) {  12. if(str == null | str.lellgth() == 0) {  13. System.out.println(”String is empty”);  14. } else {  15. System.out.println(”String is not empty”);  16. }  17. }  And the invocation:  31. test(llull);  What is the result?() 

  • A、 Au exception is thrown at runtime.
  • B、 “String is empty” is printed to output.
  • C、 Compilation fails because of au error in line 12.
  • D、 “String is not empty” is printed to output.
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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.

正确答案:D

第2题:

10. abstract public class Employee {  11. protected abstract double getSalesAmount();  12. public double getCommision() {  13. return getSalesAmount() * 0.15;  14. }  15. }  16. class Sales extends Employee {  17. // insert method here  18. }  Which two methods, inserted independently at line 17, correctly complete the Sales class?()

  • A、 double getSalesAmount() { return 1230.45; }
  • B、 public double getSalesAmount() { return 1230.45; }
  • C、 private double getSalesAmount() { return 1230.45; }
  • D、 protected double getSalesAmount() { return 1230.45; }

正确答案:B,D

第3题:

Given:10. interface Data { public void load(); }11. abstract class Info { public abstract void load(); }Which class correctly uses the Data interface and Info class?()()

A.

B.

C.

D.

E.

F.


参考答案:A

第4题:

多选题
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?()
A

A

B

B

C

C

D

D

E

E

F

F


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

第5题:

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
  • F、 abstract
  • G、 protected

正确答案:A,B,D

第6题:

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.count
  • B、 args.length
  • C、 args.count()
  • D、 args.length()
  • E、 args.getLength()

正确答案:B

第7题:

A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()

  • A、 public void setEnabled( boolean enabled) public boolean getEnabled()
  • B、 public void setEnabled( boolean enabled) public void isEnabled()
  • C、 public void setEnabled( boolean enabled) public boolean isEnabled()
  • D、 public boolean setEnabled( boolean enabled) public boolean getEnabled()

正确答案:A,C

第8题:

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、 StackOverflowError
  • B、 NullPointerException
  • C、 NumberFormatException
  • D、 IllegalArgumentException
  • E、 ExceptionlnlnitializerError

正确答案:A

第9题:

10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?() 

  • A、 Point p = Line.getPoint();
  • B、 Line.Point p = Line.getPoint();
  • C、 Point p = (new Line()).getPoint();
  • D、 Line.Point p = (new Line()).getPoint();

正确答案:D

第10题:

单选题
11. class Animal { public String noise() { return “peep”; } }  12. class Dog extends Animal {  13. public String noise() { return “bark”; }  14. }  15. class Cat extends Animal {  16. public String noise() { return “meow”; }  17. }  .....  30. Animal animal = new Dog();  31. Cat cat = (Cat)animal;  32. System.out.printIn(cat.noise());  What is the result?()
A

 peep

B

 bark

C

 meow

D

 Compilation fails.

E

 An exception is thrown at runtime.


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

更多相关问题