public class Pass{ public static void main(String[]args){ int x=5; Pass p=new Pass(); p.doStuff(x); System.out.print("mainx="+x); } void doStuff(intx){ System.out.print("doStuffx="+x++); } } What is the result?()A、Compilation fails.B、An exception is thrown at runtime.C、doStuff x=6 main x=6D、doStuff x=5 main x=5E、doStuff x=5 main x=6F、doStuff x=6 main x=5

public class Pass{ public static void main(String[]args){ int x=5; Pass p=new Pass(); p.doStuff(x); System.out.print("mainx="+x); } void doStuff(intx){ System.out.print("doStuffx="+x++); } } What is the result?()

  • A、Compilation fails.
  • B、An exception is thrown at runtime.
  • C、doStuff x=6 main x=6
  • D、doStuff x=5 main x=5
  • E、doStuff x=5 main x=6
  • F、doStuff x=6 main x=5

相关考题:

public class Pass{public static void main(String[]args){int x=5;Pass p=new Pass();p.doStuff(x);System.out.print(mainx=+x);}void doStuff(intx){System.out.print(doStuffx=+x++);}}What is the result?()A.Compilation fails.B.An exception is thrown at runtime.C.doStuff x=6 main x=6D.doStuff x=5 main x=5E.doStuff x=5 main x=6F.doStuff x=6 main x=5

Given the command line java Pass2 and:public class Pass2{public void main(String[]args){int x=6;Pass2 p=new Pass2();p.doStuff(x);System.out.print(mainx=+x);}void doStuff(intx){System.out.print(doStuffx=+x++);}}What is the result?()A.Compilation fails.B.An exception is thrown at runtime.C.doStuffx=6 main x=6D.doStuffx=6 mainx =7E.doStuffx=7 mainx =6F.doStuffx=7 mainx =7

GiventhecommandlinejavaPass2and:publicclassPass2{publicvoidmain(String[]args){intx=6;Pass2p=newPass2();p.doStuff(x);System.out.print(”mainx=+x);}voiddoStuff(intx){System.out.print(”doStuffx=+x++);}}Whatistheresult?()A.Compilationfails.B.Anexceptionisthrownatruntime.C.doStuffx=6mainx=6D.doStuffx=6mainx=7E.doStuffx=7mainx=6F.doStuffx=7mainx=7

publicclassPass{publicstaticvoidmain(String[1args){intx5;Passp=newPass();p.doStuff(x);System.out.print(”mainx=+x);}voiddoStuff(intx){System.out.print(”doStuffx=+x++);}}Whatistheresult?() A.Compilationfails.B.Anexceptionisthrownatruntime.C.doStuffx=6mainx=6D.doStuffx=5mainx=5E.doStuffx=5mainx=6F.doStuffx=6mainx=5

static void test() throws RuntimeException {  try {  System.out.print(”test “);  throw new RuntimeException();  }  catch (Exception ex) { System.out.print(”exception “); }  }  public static void main(String[] args) {  try { test(); }  catch (RuntimeException ex) { System.out.print(”runtime “); }  System.out.print(”end “);  }  What is the result?() A、 test endB、 Compilation fails.C、 test runtime endD、 test exception endE、 A Throwable is thrown by main at runtime.

public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints “bar”.D、 The code executes normally, but nothing prints.

interface DeclareStuff{  public static final int EASY = 3;  void doStuff(int t); }  public class TestDeclare implements DeclareStuff {  public static void main(String [] args) {  int x=5;  new TestDeclare().doStuff(++x);  }  void doStuff(int s) {  s += EASY + ++s;  System.out.println(”s “ + s);  }  }  What is the result?() A、 s 14B、 s 16C、 s 10D、 Compilation fails.E、 An exception is thrown at runtime.

Given the command line java Pass2 and: public class Pass2{ public void main(String[]args){ int x=6; Pass2 p=new Pass2(); p.doStuff(x); System.out.print("mainx="+x); } void doStuff(intx){ System.out.print("doStuffx="+x++); } } What is the result?()A、Compilation fails.B、An exception is thrown at runtime.C、doStuffx=6 main x=6D、doStuffx=6 mainx =7E、doStuffx=7 mainx =6F、doStuffx=7 mainx =7

public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“C”);  }  finally {  System.out.print(“B”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new Error();  }  }  What is the result?()  A、 ABCDB、 Compilation fails.C、 C is printed before exiting with an error message.D、 BC is printed before exiting with an error message.E、 BCD is printed before exiting with an error message.

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

Given the command line java Pass2 and:  public class Pass2 {  public void main(String [] args) {  int x=6;  Pass2 p = new Pass2();  p.doStuff(x);  System.out.print(” main x = “+ x); }  void doStuff(int x) {  System.out.print(” doStuffx = “+ x++);  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 doStuffx = 6 main x = 6D、 doStuffx = 6 main x = 7E、 doStuffx = 7 main x = 6F、 doStuffx = 7 main x = 7

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 Pass {  public static void main(String [1 args) {  int x 5;  Pass p = new Pass();  p.doStuff(x);  System.out.print(” main x = “+ x);  }  void doStuff(int x) {  System.out.print(” doStuff x = “+ x++);  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 doStuffx = 6 main x = 6D、 doStuffx = 5 main x = 5E、 doStuffx = 5 main x = 6F、 doStuffx = 6 main x = 5

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

单选题public class Pass {  public static void main(String [1 args) {  int x 5;  Pass p = new Pass();  p.doStuff(x);  System.out.print(” main x = “+ x);  }  void doStuff(int x) {  System.out.print(” doStuff x = “+ x++);  }  }  What is the result?()A Compilation fails.B An exception is thrown at runtime.C doStuffx = 6 main x = 6D doStuffx = 5 main x = 5E doStuffx = 5 main x = 6F doStuffx = 6 main x = 5

单选题Given the command line java Pass2 and:  public class Pass2 {  public void main(String [] args) {  int x=6;  Pass2 p = new Pass2();  p.doStuff(x);  System.out.print(” main x = “+ x); }  void doStuff(int x) {  System.out.print(” doStuffx = “+ x++);  }  }  What is the result?()A Compilation fails.B An exception is thrown at runtime.C doStuffx = 6 main x = 6D doStuffx = 6 main x = 7E doStuffx = 7 main x = 6F doStuffx = 7 main x = 7

单选题public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“C”);  }  finally {  System.out.print(“B”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new Error();  }  }  What is the result?()A ABCDB Compilation fails.C C is printed before exiting with an error message.D BC is printed before exiting with an error message.E BCD is printed before exiting with an error message.

单选题Given the command line java Pass2 and: public class Pass2{ public void main(String[]args){ int x=6; Pass2 p=new Pass2(); p.doStuff(x); System.out.print("mainx="+x); } void doStuff(intx){ System.out.print("doStuffx="+x++); } } What is the result?()ACompilation fails.BAn exception is thrown at runtime.CdoStuffx=6 main x=6DdoStuffx=6 mainx =7EdoStuffx=7 mainx =6FdoStuffx=7 mainx =7

单选题public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes normally and prints “bar”.D The code executes normally, but nothing prints.

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

单选题interface DeclareStuff{  public static final int EASY = 3;  void doStuff(int t); }  public class TestDeclare implements DeclareStuff {  public static void main(String [] args) {  int x=5;  new TestDeclare().doStuff(++x);  }  void doStuff(int s) {  s += EASY + ++s;  System.out.println(”s “ + s);  }  }  What is the result?()A s 14B s 16C s 10D Compilation fails.E An exception is thrown at runtime.

单选题public class Pass{ public static void main(String[]args){ int x=5; Pass p=new Pass(); p.doStuff(x); System.out.print("mainx="+x); } void doStuff(intx){ System.out.print("doStuffx="+x++); } } What is the result?()ACompilation fails.BAn exception is thrown at runtime.CdoStuff x=6 main x=6DdoStuff x=5 main x=5EdoStuff x=5 main x=6FdoStuff x=6 main x=5