• 2022-06-07
    调用以下类D和E的main() 方法的输出结果为?class D { public static void main(String[] args) { String s1 = new String("hello"); String s2 = new String("hello"); if (s1.equals(s2)) System.out.println("equal"); else System.out.println("not equal"); }} class E { public static void main(String[] args) { StringBuffer sb1 = new StringBuffer("hello"); StringBuffer sb2 = new StringBuffer("hello"); if (sb1.equals(sb2)) System.out.println("equal"); else System.out.println("not equal"); }}
    A: D: equal; E: equal
    B: D: not equal; E: not equal
    C: D: equal; E: not equal
    D: D: not equal; E: equal
  • C

    内容

    • 0

      public class Test { public static void main(String[] args) { String s1 = "abc"; String s2 = new String ("abc"); System.out.println(s1 == s2); } } 程序运行结果是

    • 1

      5、下列程序的运行结果是()。public static void main( String[] args ){StringBuffer sb = new StringBuffer();sb.append("qq").append("ww");show( sb, "ss" );System.out.println( sb.length() );}public void show( StringBuffer sb, String str ){sb.append( str );} A: 4 B: 2 C: 6 D: 0

    • 2

      class Test { public static void main(String[] args) { StringBuffer sb = new StringBuffer("hello world"); sb.replace(6, sb.length(), "java"); System.out.println( sb.toString() ); } } 选择正确的运行结果 A: hello javad B: hellojava C: hello java

    • 3

      class Test { public static void main(String[] args) { StringBuffer sb = new StringBuffer("abcd"); sb.reverse(); System.out.println( sb.toString() ); } } 代码的输出结果是: dcba

    • 4

      import java.io.*;public class abc{public static void main(String args[ ]){ AB s = new AB("Hello!",“world”);System.out.println(s.toString( ));}} class AB {String s1;String s2;AB( String str1 , String str2 ){ s1 = str1; s2 = str2; }public String toString( ){ return s1+s2; }} A: Hello!world B: worldHello!