public class X {   public static void main (Stringargs) {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s) {   s += “world!”;   }   }   What is the result?() A、The program runs and prints “Hello”B、An error causes compilation to fail.C、The program runs and prints “Hello world!”D、The program runs but aborts with an exception.

public class X {   public static void main (Stringargs) {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s) {   s += “world!”;   }   }   What is the result?() 

  • A、The program runs and prints “Hello”
  • B、An error causes compilation to fail.
  • C、The program runs and prints “Hello world!”
  • D、The program runs but aborts with an exception.

相关考题:

下列程序的运行结果是【 】。public class Test {public static void main (String args[]) {String s1="hello!";System.out.println (s1.toUpperCase());}}

下列语句输出结果为( )。 public class test\ { public static void main (String args[]) { String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1.equals(s2))); } }A.falseB.trueC.0D.1

下列语句输出结果为( )。 public class test { public static void main(StringArgsl[]) { String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); } }A.falseB.trueC.1D.0

下列程序的输出结果是( )。 public class Test { public static void main (String[] args) { String s="hello"; s.replace ('r','m'); System.out.println(s); } }A.helloB.HELLOC.hemmoD.HEMMO

public class foo {   public static void main (Stringargs) {  String s;   system.out.printIn (“s=” + s);   }   }   What is the result?()A、 The code compiles and “s=” is printed.B、 The code compiles and “s=null” is printed.C、 The code does not compile because string s is not initialized.D、 The code does not compile because string s cannot be referenced.E、 The code compiles, but a NullPointerException is thrown when toString is called.

public class Test {   public static void main (String args) {  string foo = “blue”;  string bar = foo;   foo = “green”;   System.out.printIn(bar);   }   }   What is the result?()  A、 An exception is thrown.B、 The code will not compile.C、 The program prints “null”D、 The program prints “blue”E、 The program prints “green”

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

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.

1. public class X {  2. public static void main (String[]args)   {  3. int [] a = new int [1]  4. modify(a);  5. System.out.printIn(a[0]);  6. }  7.    8. public static void modify (int[] a)  {  9.   a[0] ++;  10.    } 11. }       What is the result?()A、 The program runs and prints “0”B、 The program runs and prints “1”C、 The program runs but aborts with an exception.D、 An error “possible undefined variable” at line 4 causes compilation to fail.E、 An error “possible undefined variable” at line 9 causes compilation to fail.

public class X {   public static void main (Stringargs) {   int a = new int [1]   modify(a);   System.out.printIn(a[0]);   }   public static void modify (int a) {   a[0] ++;    }    }   What is the result?()  A、 The program runs and prints “0”B、 The program runs and prints “1”C、 The program runs but aborts with an exception.D、 An error “possible undefined variable” at line 4 causes compilation to fail.E、 An error “possible undefined variable” at line 9 causes compilation to fail.

Given:  310-025   Leading the way in IT testing and certification tools, www.testking.com   - 48 -   public class foo {   static String s;   public static void main (Stringargs) {   system.out.printIn (“s=” + s);   }   }   What is the result?()A、 The code compiles and “s=” is printed.B、 The code compiles and “s=null” is printed.C、 The code does not compile because string s is not initialized.D、 The code does not compile because string s cannot be referenced.E、 The code compiles, but a NullPointerException is thrown when toString is called.

public class foo {  public static void main (String[]args) {  String s;  system.out.printIn (“s=” + s);  }  }   What is the result?()  A、 The code compiles and “s=” is printed.B、 The code compiles and “s=null” is printed.C、 The code does not compile because string s is not initialized.D、 The code does not compile because string s cannot be referenced.E、 The code compiles, but a NullPointerException is thrown when toString is called.

public class foo {  static String s;  public static void main (String[]args) {  system.out.printIn (“s=” + s);  } }  What is the result?()  A、 The code compiles and “s=” is printed.B、 The code compiles and “s=null” is printed.C、 The code does not compile because string s is not initialized.D、 The code does not compile because string s cannot be referenced.E、 The code compiles, but a NullPointerException is thrown when toString is called.

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.

public class X {   public static void main (String[]args)   {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s)  {   s += “world!”;      }   }      What is the result?()    A、 The program runs and prints “Hello”B、 An error causes compilation to fail.C、 The program runs and prints “Hello world!”D、 The program runs but aborts with an exception.

public class Test {  public static void replaceJ(string text)  {  text.replace (‘j’, ‘l’);  }  public static void main(String args[])  {  string text = new String (“java”)  replaceJ(text);  system.out.printIn(text);  }  }      What is the result?()  A、 The program prints “lava”B、 The program prints “java”C、 An error at line 7 causes compilation to fail.D、 Compilation succeeds but the program throws an exception.

单选题1. public class X {  2. public static void main (String[]args)   {  3. int [] a = new int [1]  4. modify(a);  5. System.out.printIn(a[0]);  6. }  7.    8. public static void modify (int[] a)  {  9.   a[0] ++;  10.    } 11. }       What is the result?()A The program runs and prints “0”B The program runs and prints “1”C The program runs but aborts with an exception.D An error “possible undefined variable” at line 4 causes compilation to fail.E An error “possible undefined variable” at line 9 causes compilation to fail.

单选题Given:  310-025   Leading the way in IT testing and certification tools, www.testking.com   - 48 -   public class foo {   static String s;   public static void main (Stringargs) {   system.out.printIn (“s=” + s);   }   }   What is the result?()A The code compiles and “s=” is printed.B The code compiles and “s=null” is printed.C The code does not compile because string s is not initialized.D The code does not compile because string s cannot be referenced.E The code compiles, but a NullPointerException is thrown when toString is called.

单选题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 X {   public static void main (Stringargs) {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s) {   s += “world!”;   }   }   What is the result?()AThe program runs and prints “Hello”BAn error causes compilation to fail.CThe program runs and prints “Hello world!”DThe program runs but aborts with an exception.

单选题public class X {   public static void main (String[]args)   {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s)  {   s += “world!”;      }   }      What is the result?()A The program runs and prints “Hello”B An error causes compilation to fail.C The program runs and prints “Hello world!”D The program runs but aborts with an exception.

单选题public class foo {  public static void main (String[]args) {  String s;  system.out.printIn (“s=” + s);  }  }   What is the result?()A The code compiles and “s=” is printed.B The code compiles and “s=null” is printed.C The code does not compile because string s is not initialized.D The code does not compile because string s cannot be referenced.E The code compiles, but a NullPointerException is thrown when toString is called.

单选题public class foo {   public static void main (Stringargs) {  String s;   system.out.printIn (“s=” + s);   }   }   What is the result?()A The code compiles and “s=” is printed.B The code compiles and “s=null” is printed.C The code does not compile because string s is not initialized.D The code does not compile because string s cannot be referenced.E The code compiles, but a NullPointerException is thrown when toString is called.

单选题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 Test {  public static void main (String [] args)  {  string foo = “blue”;  string bar = foo;  foo = “green”;  System.out.printIn(bar);  }  }   What is the result?()A An exception is thrown.B The code will not compile.C The program prints “null”D The program prints “blue”E The program prints “green”

单选题public class X {   public static void main (Stringargs) {   int a = new int [1]   modify(a);   System.out.printIn(a[0]);   }   public static void modify (int a) {   a[0] ++;    }    }   What is the result?()A The program runs and prints “0”B The program runs and prints “1”C The program runs but aborts with an exception.D An error “possible undefined variable” at line 4 causes compilation to fail.E An error “possible undefined variable” at line 9 causes compilation to fail.