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

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

public class Test{ public static void main(String[]args){ intx=5; boolean b1=true; boolean b2=false; if((x==4)&&!b2) System.out.print("l"); System.out.print("2"); if((b2=true)&&b1) System.out.print("3"); } } What is the result?()

  • A、2
  • B、3
  • C、12
  • D、23
  • E、123
  • F、Compilation fails.
  • G、An exceptional ist hrown at runtime.

参考答案

更多 “ public class Test{ public static void main(String[]args){ intx=5; boolean b1=true; boolean b2=false; if((x==4)!b2) System.out.print("l"); System.out.print("2"); if((b2=true)b1) System.out.print("3"); } } What is the result?()A、2B、3C、12D、23E、123F、Compilation fails.G、An exceptional ist hrown at runtime.” 相关考题
考题 以下程序段输出结果为( )。 class test_1 { public static void main(String args[]) { int x=0; boolean b1,b2,b3,b4; b1=b2=b3=b4=true; x=(b1|b2b3^b4)?x++:--x; System.out.println(x); } }A.1B.0C.2D.3

考题 public class Test{public static void main(String[]args){intx=5;boolean b1=true;boolean b2=false;if((x==4)!b2)System.out.print(l);System.out.print(2);if((b2=true)b1)System.out.print(3);}}What is the result?()A.2B.3C.12D.23E.123F.Compilation fails.G.An exceptional ist hrown at runtime.

考题 publicclassTest{publicstaticvoidmain(String[]args){intx=5;booleanb1=true;booleanb2=false;if((x==4)!b2)System.out.print(”l);System.out.print(”2);if((b2=true)b1)System.out.print(”3);}}Whatistheresult?()A.2B.3C.12D.23E.123F.Compilationfails.G.Auexceptionalisthrownatruntime.

考题 以下程序段输出结果为( )。 class test_1 { public static void main(String args[]) { int x=0; boolean bl,b2,b3,b4; b1=b2=b3=b4=true; x=(b1|b2b3^b4)?x++:--x; System.out.println(x); } }A.1B.0C.2D.3

考题 下列代码的执行结果是______。 public class ex55 { public static void main(String args[] ) { String s1=new String("hello"); String s2=new String("hello"); System.out.print (s1==s2); System.out.print (","); System.out.println (s1.equals (s2)); } }A.true, falseB.true, trueC.false, trueD.false, false

考题 下列选项中,哪个是程序的运行结果class Test{public static void main(String[] args) {int a = 3;int b = 6;System.out.print(a==b);System.out.print(aSystem.out.print(a!=b);System.out.print(a>=b);}} A.false false true falseB.false false true trueC.false true true falseD.true false false true

考题 class One {  public One() { System.out.print(1); }  }  class Two extends One {  public Two() { System.out.print(2); }  }  class Three extends Two {  public Three() { System.out.print(3); }  }  public class Numbers{  public static void main( String[] argv) { new Three(); }  }  What is the result when this code is executed?() A、 1B、 3C、 123D、 321E、 The code rims with no output.

考题 现有:  class Waiting implements Runnable  {       boolean flag=false;  public  synchronized void run()  {       if  (flag)  {       flag=false;  System.out.print ("1");  try  {  this.wait();  )  catch  (Exception e)  {  }       System.out.print ("2");       }  else  {       flag=true;  System.out.print ("3");  try{Thread.sleep (2000); } catch(Exception e)  {}      System.out.print ("4");       notify();       }       }  public static void main (String  []  args)  {       Waiting w=new Waiting();       new Thread (w) .start();       new Thread (w) .start();       }       }  以下哪两项是正确的?()    A、代码输出l 3 4B、代码输出3 4 1C、代码输出l 2 3 4D、代码输出1 3 4 2E、代码运行完毕F、代码不会完成

考题 public class Test {  public static void main(String [] args) {  int x =5;  boolean b1 = true;  boolean b2 = false;  if((x==4)  !b2)  System.out.print(”l “);  System.out.print(”2 “);  if ((b2 = true)  b1)  System.out.print(”3 “);  } }  What is the result?() A、 2B、 3C、 1 2D、 2 3E、 1 2 3F、 Compilation fails.G、 Au exceptional is thrown at runtime.

考题 public class Base {  public static final String FOO = “foo”;  public static void main(String[] args) {  Base b = new Base();  Sub s = new Sub();  System.out.print(Base.FOO);  System.out.print(Sub.FOO);  System.out.print(b.FOO);  System.out.print(s.FOO);  System.out.print(((Base)s).FOO);  } }  class Sub extends Base {public static final String FOO=bar;}  What is the result?() A、 foofoofoofoofooB、 foobarfoobarbarC、 foobarfoofoofooD、 foobarfoobarfooE、 barbarbarbarbarF、 foofoofoobarbarG、 foofoofoobarfoo

考题 static void test() {  try {  String x=null;  System.out.print(x.toString() +“ “);  }  finally { System.out.print(“finally “); }  }  public static void main(String[] args) {  try { test(); }  catch (Exception ex) { System.out.print(”exception “); }  }  What is the result?() A、 nullB、 finallyC、 null finallyD、 Compilation fails.E、 finally exception

考题 public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”); }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }   public static void badMethod() {} }  What is the result?()  A、 ACB、 BDC、 ACDD、 ABCDE、 Compilation fails.

考题 public class Delta {  static boolean foo(char c) {  System.out.print(c);  return true;  }  public static void main( String[] argv ) {  int i =0;  for ( foo(‘A’); foo(‘B’)(i2); foo(‘C’)){  i++ ;  foo(‘D’);  }  }  }  What is the result?()  A、 ABDCBDCBB、 ABCDABCDC、 Compilation fails.D、 An exception is thrown at runtime.

考题 public class X {   public static void main (Stringargs) {   String s1 = new String (“true”);   Boolean b1 = new Boolean (true);   if (s2.equals(b1)) {   System.out.printIn(“Equal”);   }   }   }   What is the result? () A、 The program runs and prints nothing.B、 The program runs and prints “Equal”C、 An error at line 5 causes compilation to fail.D、 The program runs but aborts with an exception.

考题 public class X {  public static void main (String[]args)  {  String s1 = new String (“true”);  Boolean b1 = new Boolean (true);  if (s2.equals(b1))   {  System.out.printIn(“Equal”);  }  }  }      What is the result?()  A、 The program runs and prints nothing.B、 The program runs and prints “Equal”C、 An error at line 5 causes compilation to fail.D、 The program runs but aborts with an exception.

考题 class Waiting implements Runnable {  boolean flag = false;  public synchronized void run() {  if (flag) {  flag = false;  System.out.print("1 ");  try { this.wait(); } catch (Exception e) { }  System.out.print("2 ");  }  else {  flag = true;  System.out.print("3 ");  try { Thread.sleep(2000); } catch (Exception e) { }  System.out.print("4 ");  notify();  }  }  public static void main(String [] args) {  Waiting w = new Waiting();  new Thread(w).start();  new Thread(w).start ();  }  }  以下哪两项是正确的?() A、代码输出 1 3 4B、代码输出 3 4 1C、代码输出 1 2 3 4D、代码不会完成

考题 public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (RuntimeException ex) {  System.out.print(“B”);  }  catch (Exception ex1) {  System.out.print(“C”);  }   finally {  System.out.print(“D”);  }  System.out.print(“E”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result?()  A、 BDB、 BCDC、 BDED、 BCDEE、 ABCDEF、 Compilation fails.

考题 public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result? () A、 ABB、 BCC、 ABCD、 BCDE、 Compilation fails.

考题 static void test() throws Error {  if (true) throw new AssertionError();  System.out.print(”test “);  }  public static void main(String[] args) {  try { test(); }  catch (Exception ex) { System.out.print(”exception “); }  System.out.print(”elld “);  }  What is the result?() A、 endB、 Compilation fails.C、 exception endD、 exception test endE、 A Throwable is thrown by main.F、 An Exception is thrown by main.

考题 单选题public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (RuntimeException ex) {  System.out.print(“B”);  }  catch (Exception ex1) {  System.out.print(“C”);  }   finally {  System.out.print(“D”);  }  System.out.print(“E”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result?()A  BDB  BCDC  BDED  BCDEE  ABCDEF  Compilation fails.

考题 单选题static void test() {  try {  String x=null;  System.out.print(x.toString() +“ “);  }  finally { System.out.print(“finally “); }  }  public static void main(String[] args) {  try { test(); }  catch (Exception ex) { System.out.print(”exception “); }  }  What is the result?()A  nullB  finallyC  null finallyD  Compilation fails.E  finally exception

考题 多选题class Waiting implements Runnable {  boolean flag = false;  public synchronized void run() {  if (flag) {  flag = false;  System.out.print("1 ");  try { this.wait(); } catch (Exception e) { }  System.out.print("2 ");  }  else {  flag = true;  System.out.print("3 ");  try { Thread.sleep(2000); } catch (Exception e) { }  System.out.print("4 ");  notify();  }  }  public static void main(String [] args) {  Waiting w = new Waiting();  new Thread(w).start();  new Thread(w).start ();  }  }  以下哪两项是正确的?()A代码输出 1 3 4B代码输出 3 4 1C代码输出 1 2 3 4D代码不会完成

考题 单选题public class X {  public static void main (String[]args)  {  String s1 = new String (“true”);  Boolean b1 = new Boolean (true);  if (s2.equals(b1))   {  System.out.printIn(“Equal”);  }  }  }      What is the result?()A  The program runs and prints nothing.B  The program runs and prints “Equal”C  An error at line 5 causes compilation to fail.D  The program runs but aborts with an exception.

考题 单选题public class Delta {  static boolean foo(char c) {  System.out.print(c);  return true;  }  public static void main( String[] argv ) {  int i =0;  for ( foo(‘A’); foo(‘B’)(i2); foo(‘C’)){  i++ ;  foo(‘D’);  }  }  }  What is the result?()A  ABDCBDCBB  ABCDABCDC  Compilation fails.D  An exception is thrown at runtime.

考题 单选题public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result? ()A  ABB  BCC  ABCD  BCDE  Compilation fails.

考题 单选题public class Test{ public static void main(String[]args){ intx=5; boolean b1=true; boolean b2=false; if((x==4)!b2) System.out.print("l"); System.out.print("2"); if((b2=true)b1) System.out.print("3"); } } What is the result?()A 2B 3C 12D 23E 123F Compilation fails.G An exceptional ist hrown at runtime.

考题 单选题public class Test {  public static void main(String [] args) {  int x =5;  boolean b1 = true;  boolean b2 = false;  if((x==4)  !b2)  System.out.print(”l “);  System.out.print(”2 “);  if ((b2 = true)  b1)  System.out.print(”3 “);  } }  What is the result?()A  2B  3C  1 2D  2 3E  1 2 3F  Compilation fails.G  Au exceptional is thrown at runtime.