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

题目内容 (请给出正确答案)
单选题
Given the following code:     if (x>0) {  System.out.println("first");  }     else if (x>-3) {  System.out.println("second");  }     else {  System.out.println("third");  }  Which range of x value would print the string "second"?()
A

 x > 0

B

 x > -3

C

 x <= -3

D

 x <= 0 & x > -3


参考答案

参考解析
解析: x>0时打印"first",x>-3&&x<=0时打印"second",x<=-3时打印"third"。这个题目没有什么难的,只要理解if语句的语法就可以了。
更多 “单选题Given the following code:     if (x0) {  System.out.println("first");  }     else if (x-3) {  System.out.println("second");  }     else {  System.out.println("third");  }  Which range of x value would print the string "second"?()A  x  0B  x  -3C  x = -3D  x = 0  x  -3” 相关考题
考题 What happens when you try to compile and run the following program?class Mystery{String s;public static void main(String[] args){Mystery m=new Mystery();m.go();}void Mystery(){s=”constructor”;}void go(){System.out.println(s);}}()A.this code will not compileB.this code compliles but throws an exception at runtimeC.this code runs and “constructor” in the standard outputD.this code runs and writes “null” in the standard output

考题 下列代码中if(x>0){System.out.println("first");} else if(x>-3)(System.out.println("second");} else{ System.out.println("third");}要求打印字符串为"second"时,x的取值范围是A.x<=0 并且 x>-3B.x>0C.x>-3D.x<=-3

考题 给出下面程序段if(x>0){System.out.println“Hello.“;}elseif(x>-3){System.out.println“Nicetomeetyou“;}else{System.out.println“Howareyou“;}若打印字符串“Howareyou”,则x的取值范围是()。 A.x>0B.x>-3C.xD.x-3

考题 Giventhefollowingcode:if(x0){System.out.println(first);}elseif(x-3){System.out.println(second);}else{System.out.println(third);}Whichrangeofxvaluewouldprintthestringsecond?()A.x0B.x-3C.x=-3D.x=0x-3

考题 给出下面程序段: if(x>0){System.out.println("Hello.");} else if(x>-3){ System.out.println("Nice to meet you!");} else{System.out.println("How are you?");} 若打印字符串"How are yoh?",则x的取值范围是( )。A.x>0B.x>-3C.x≤-3D.x≤0x>-3

考题 下列代码中 if(xO){System.out.println("first");} elseif(x-3){System.out.println("second");) else{System.out.println("third");) 要求打印字符串为“second”时,X的取值范围是( )。A.x=0且x-3B.x0C.x-3D.x=-3

考题 给出下列代码片段: if(x>0){System.out.println("first");} else if(x>-3){System.out.println("second");} else{System.out.println("third");} 当x处于( )范围时打印字符串"second"。A.x>0B.x>-3C.-3<x<=0D.x<=-3

考题 Given the following code:     if (x0) {  System.out.println("first");  }     else if (x-3) {  System.out.println("second");  }     else {  System.out.println("third");  }  Which range of x value would print the string "second"?()    A、 x  0B、 x  -3C、 x = -3D、 x = 0  x  -3

考题 public class Foo {  public void main( String[] args ) {  System.out.println( “Hello” + args[0] );  }  }   What is the result if this code is executed with the command line?()A、 HelloB、 Hello FooC、 Hello worldD、 Compilation fails.E、 The code does not run.

考题 What will be the result of attempting to compile and run the following code?()   public class Q6b0c {   public static void main(String args[]) {  int i = 4;  float f = 4.3;   double d = 1.8;   int c = 0;   if (i == f) c++;   if (((int) (f + d)) == ((int) f + (int) d))  c += 2;   System.out.println(c);   }   }  A、The code will fail to compile.B、0 will be written to the standard output.C、1 will be written to the standard output.D、2 will be written to the standard output.E、3 will be written to the standard output.

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

考题 Given the following code fragment:      1) String str = null;  2) if ((str != null)  (str.length()  10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null)  (str.length()  5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()    A、 line 1B、 line 2C、 line 5D、 line 8

考题 Given the following code:     public class Person{     int arr[] = new int[10];  public static void main(String a[]) {     System.out.println(arr[1]);     }     }  Which statement is correct?() A、 When compilation some error will occur.B、 It is correct when compilation but will cause error when running.C、 The output is zero.D、 The output is null.

考题 Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()   CODE FRAGMENT a:   public static void main(String args[]) {   if (args.length != 0)   System.out.println(args[args.length-1]);   }   CODE FRAGMENT b:   public static void main(String args[]) {   try { System.out.println(args[args.length]); }   catch (ArrayIndexOutOfBoundsException e) {}   }   CODE FRAGMENT c:   public static void main(String args[]) {   int ix = args.length;   String last = args[ix];   if (ix != 0) System.out.println(last);   }   CODE FRAGMENT d:   public static void main(String args[]) {   int ix = args.length-1;   if (ix  0) System.out.println(args[ix]);   }   CODE FRAGMENT e:   public static void main(String args[]) {   try { System.out.println(args[args.length-1]);  }catch (NullPointerException e) {}   }  A、Code fragment a.B、Code fragment b.C、Code fragment c.D、Code fragment d.E、Code fragment e.

考题 单选题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 4B  line 6C  line 7D  line 8

考题 多选题10.publicclassBar{ 11.staticvoidfoo(int...x){ 12.//insertcodehere 13.} 14.} Which two code fragments,inserted independently at line1 2,will allow the class to compile()Aforeach(x)System.out.println(z);Bfor(intz:x)System.out.println(z);Cwhile(x.hasNext())System.out.println(x.next());Dfor(inti=0;i

考题 单选题Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()   CODE FRAGMENT a:   public static void main(String args[]) {   if (args.length != 0)   System.out.println(args[args.length-1]);   }   CODE FRAGMENT b:   public static void main(String args[]) {   try { System.out.println(args[args.length]); }   catch (ArrayIndexOutOfBoundsException e) {}   }   CODE FRAGMENT c:   public static void main(String args[]) {   int ix = args.length;   String last = args[ix];   if (ix != 0) System.out.println(last);   }   CODE FRAGMENT d:   public static void main(String args[]) {   int ix = args.length-1;   if (ix  0) System.out.println(args[ix]);   }   CODE FRAGMENT e:   public static void main(String args[]) {   try { System.out.println(args[args.length-1]);  }catch (NullPointerException e) {}   }A Code fragment a.B Code fragment b.C Code fragment c.D Code fragment d.E Code fragment e.

考题 单选题What will be the result of attempting to compile and run the following code?()   public class Q6b0c {   public static void main(String args[]) {  int i = 4;  float f = 4.3;   double d = 1.8;   int c = 0;   if (i == f) c++;   if (((int) (f + d)) == ((int) f + (int) d))  c += 2;   System.out.println(c);   }   }A The code will fail to compile.B 0 will be written to the standard output.C 1 will be written to the standard output.D 2 will be written to the standard output.E 3 will be written to the standard output.

考题 多选题Given the following class, which statements can be inserted at position 1 without causing the code to fail compilation?()   public class Q6db8 {   int a;   int b = 0;   static int c;   public void m() {   int d;   int e = 0;   // Position 1   }   }Aa++;Bb++;Cc++;Dd++;Ee++;

考题 单选题Given the following code:     public class Person{ static int arr[] = new int[10];  public static void main(String a[]) {     System.out.println(arr[1];)     }     }  Which statement is correct?()A  When compilation some error will occur.B  It is correct when compilation but will cause error when running.C  The output is zero.D  The output is null.

考题 填空题Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.   class Base {   public void print( ) {   System.out.println("base");   }   }   class Extention extends Base {   public void print( ) {   System.out.println("extension");   // insert line of implementation here   }   }   public class Q294d {   public static void main(String args[]) {   Extention ext = new Extention( );   ext.print( );   }   }   Fill in a single line of implementation.()

考题 单选题Given the following code fragment:      1) String str = null;  2) if ((str != null)  (str.length()  10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null)  (str.length()  5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()A  line 1B  line 2C  line 5D  line 8

考题 单选题Given the following code:     if (x0) {  System.out.println("first");  }     else if (x-3) {  System.out.println("second");  }     else {  System.out.println("third");  }  Which range of x value would print the string "second"?()A  x  0B  x  -3C  x = -3D  x = 0  x  -3

考题 多选题Given the following code, which statements concerning the objects referenced through the member variables i, j and k are true, given that any thread may call the methods a, b and c at any time? ()  class Counter {  int v = 0;   synchronized void inc() { v++; }   synchronized void dec() { v--; }   }   public class Q7ed5 {   Counter i;   Counter j;   Counter k;   public synchronized void a() {   i.inc();   System.out.println("a");   i.dec();  }   public synchronized void b() {   i.inc();  j.inc();  k.inc();   System.out.println("b");  i.dec();  j.dec(); k.dec();  }   public void c() {   k.inc();   System.out.println("c");   k.dec();   }   }Ai.v is guaranteed always to be 0 or 1.Bj.v is guaranteed always to be 0 or 1.Ck.v is guaranteed always to be 0 or 1Dj.v will always be greater than or equal to k.v at any give time.Ek.v will always be greater than or equal to j.v at any give time.

考题 单选题Given the following code:     public class Person{     int arr[] = new int[10];  public static void main(String a[]) {     System.out.println(arr[1]);     }     }  Which statement is correct?()A  When compilation some error will occur.B  It is correct when compilation but will cause error when running.C  The output is zero.D  The output is null.

考题 单选题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 8B  The value is 9C  The value is 10D  The value is 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.

考题 多选题10. public class Bar {  11.static void foo(int...x) {  12. // insert code here  13. }  14. }  Which two code fragments, inserted independently at line 12, will allow the class to compile?()Aforeach(x) System.out.println(z);Bfor(int z : x) System.out.println(z);Cwhile( x.hasNext()) System.out.println( x.next());Dfor( int i=0; i x.length; i++ ) System.out.println(x[i]);