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

题目内容 (请给出正确答案)
单选题
public String makinStrings() {  String s = “Fred”;  s = s + “47”;  s = s.substring(2, 5);  s = s.toUpperCase();  return s.toString();  }  How many String objects will be created when this method is invoked?()
A

 1

B

 2

C

 3

D

 4

E

 5

F

 6


参考答案

参考解析
解析: 暂无解析
更多 “单选题public String makinStrings() {  String s = “Fred”;  s = s + “47”;  s = s.substring(2, 5);  s = s.toUpperCase();  return s.toString();  }  How many String objects will be created when this method is invoked?()A  1B  2C  3D  4E  5F  6” 相关考题
考题 下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i,String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String[]args){ print(99,"Int first"); } }A.String:String first,int:11B.int:11,String:Int firstC.String:String first,int99D.int:99,String:Int first

考题 下面的程序执行后,屏幕上显示的应是 public class Exam{ public static void main(String[]args){ char char1[]={'t','e','s','t'}; char char2[]={'t','e','S','t','1'}; String s1=new String(char1); String s2=new String(char2,0,4); System.out.println(s1.equals(s2)); } }A.trueB.falseC.testD.编译错误

考题 下列语句输出结果为( )。 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{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i, String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String [] args){ print(99,"Int first"); } }A.String:Stringfirst,int:11B.int:11,String:Int firstC.String:String first,int:99D.int:99,String:int first

考题 下列程序的执行结果是______。 public class Test9 { public static void main(String[] args) { String s1 = new String("I am a girl"); String s2 = new String("I am a girl"); System.out.println (s1.equal (s2)); } }A.trueB.假C.I amgirlD.都不正确

考题 阅读下面程序 public class OperatorsAndExpressions{ void equalsMethodl(){ String s1=new String("how are you"); String s2=new String("how are you"); System.out.println(s1==s2); } public static void main(String args[]){ OperatorsAndExpressionsOperAndExp=new OperatorsAndExpressions(); //用于复合类型数据的“==”运算符 OperAndExp.equalsMethod1(); } } 程序运行结果是A.=B.trueC.falseD.equal

考题 给出下面不完整的类代码,则横线处的语句应该为( )。 class Person { String name,department; int age; public Person (Strings) {name=s;} public Person (String s,intA.{name=s;age=a;} public Person (String n,String d,intA){ __________ department=d; } }A)Person (n,A);B.this (Person(n,A));C.this(n,A);D.this(name,age);

考题 下列语句输出结果为( )。 public class test { public static void main(String args[]) String s1 =newString("HOW"); String s2=newString("How"): System.out.pnntln(!(s1.equals(s2))); } }A.假B.真C.0D.1

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

考题 阅读下面程序 public class OperatorsAndExpressions { void equalsMethodl(){ String s1=new String("how are you"); String s2=new String("how are you"); System.out.println(s1==s2); } public static void main(String args[]){ OperatorsAndExpressions perAndExp=new OperatorsAndExpressions(); OperAndExp.equalsMethod1(); } } 程序运行结果是( )。A. ==B.trueC.假D.equal

考题 下列语句输出结果为( )。 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 s1= new String("hello"); String s2= new String("hello"); System.out.println(s1==s2); System.out.println(s1.equal(s2)); } }A.true falseB.true trueC.false trueD.false false

考题 下列代码的执行结果是______。 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

考题 下列程序的输出结果是( )。 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

考题 3下列程序段运行的结果为( )。 public class Test{ static void print(String s,int i){ System.out.pdntlnC String: "+s+",int:"+i); } static void print(iht i,String s){ System.out.prinflnCint:"+i+",gtring:"+s); } public static void main(String[] args){ print(99,"Int first"); } }A.String:String first,int: 11B.int: 11,String:Int firstC.String:String first,int:99D. int:99,Stfing:Int first

考题 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 String makinStrings() {  String s = “Fred”;  s = s + “47”;  s = s.substring(2, 5);  s = s.toUpperCase();  return s.toString();  }  How many String objects will be created when this method is invoked?() A、 1B、 2C、 3D、 4E、 5F、 6

考题 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 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 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.

考题 Which of the following fragments might cause errors?()    A、 String s = "Gone with the wind";String t = " good ";String k = s + t;B、 String s = "Gone with the wind";String t;t = s[3] + "one";C、 String s = "Gone with the wind";String standard = s.toUpperCase();D、 String s = "home directory";String t = s - "directory";

考题 import java.util.*;  public class WrappedString {  private String s;  public WrappedString(String s) { this.s = s; }  public static void main(String[] args) {  HashSet hs = new HashSet();  WrappedString ws1 = new WrappedString(”aardvark”);  WrappedString ws2 = new WrappedString(”aardvark”);  String s1 = new String(”aardvark”);  String s2 = new String(”aardvark”);  hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);  System.out.println(hs.size()); } }  What is the result?()  A、 0B、 1C、 2D、 3E、 4F、 Compilation fails.G、 An exception is thrown at runtime.

考题 单选题import java.util.*;  public class WrappedString {  private String s;  public WrappedString(String s) { this.s = s; }  public static void main(String[] args) {  HashSet hs = new HashSet();  WrappedString ws1 = new WrappedString(”aardvark”);  WrappedString ws2 = new WrappedString(”aardvark”);  String s1 = new String(”aardvark”);  String s2 = new String(”aardvark”);  hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);  System.out.println(hs.size()); } }  What is the result?()A  0B  1C  2D  3E  4F  Compilation fails.G  An exception is thrown at runtime.

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

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