Which fragment is an example of inappropriate use of assertions? ()A、 assert (!(map.contains(x))); map.add(x);B、 if (x  0){}else { assert (x==0); }C、 public void aMethod(int x) { assert (x  0); }D、 assert (invariantCondition()); return retval;E、 switch (x) { case 1: break; case 2: creak; default: assert (x == 0);

Which fragment is an example of inappropriate use of assertions? ()

  • A、 assert (!(map.contains(x))); map.add(x);
  • B、 if (x > 0){}else { assert (x==0); }
  • C、 public void aMethod(int x) { assert (x > 0); }
  • D、 assert (invariantCondition()); return retval;
  • E、 switch (x) { case 1: break; case 2: creak; default: assert (x == 0);

相关考题:

class Guy{String greet(){return “hi“}}   class Cowboy extends Guy {String greet(){return“howdy”}}   class Surfer extends Guy {String greet(){return“dudel”}}  class Greetings{   public static void main (string[]args){   Guy[] guy= {new Guy(),new Cowboy(),new Surfer()};   for(Guy 0: guys)   System.out.print(g.green());  }   }   结果为:  A、运行时异常被输出B、第7行出现一个错误,编译失败C、第8行出现一个错误,编译失败D、hi hi hiE、hi hawdy doude

Which two are true about authentication?()A、Form-based logins should NOT be used with HTTPS.B、When using Basic Authentication the target server is NOT authenticated.C、J2EE compliant web containers are NOT required to support the HTTPS protocol.D、Web containers are required to support unauthenticated access to unprotected web resources.

启动一个线程的方法是哪项?()     A、 join()B、 run ()C、start()D、sleep()

1. package foo;  2.    3. import java.util.Vector;  4.    5. private class MyVector extends Vector {  6. int i = 1;  7. public MyVector()  {  8. i = 2;  9.    }  10. }  11.    12. public class MyNewVector extends MyVector {  13. public MyNewVector ()  {  14. i = 4;  15. }  16. public static void main (String args [])  {  17. MyVector v = new MyNewVector();  18.   }  19. }     The file MyNewVector.java is shown in the exhibit.  What is the result?()  A、 Compilation will succeed.B、 Compilation will fail at line 5.C、 Compilation will fail at line 6.D、 Compilation will fail at line 14.E、 Compilation will fail at line 17.

public class IfTest (  public static void main(string[]args) {  int x = 3;  int y = 1;  if (x = y)  system.out.printIn(“Not equal”);  else  system.out.printIn(“Equal”);  }  )   What is the result?()      A、 The output is “Equal”B、 The output in “Not Equal”C、 An error at line 5 causes compilation to fall.D、 The program executes but does not print a message.

class TestApp{   public static void main(String[] args){   System.out.println(multiply(2,3,4,5));  }   public int multiply(int... nums){   int result=1;   for(int x:nums)   result*=x;   return result;  }  }   程序运行后的输出是哪项?()  A、120B、24C、14D、编译错误

Java的字符采用何种编码方案?有何特点?写出五个常见的转义符。