• 2022-06-08
    关于以下程序段,运行结果是()1.String  s1 =“a”+“b”;  2.String  s2 = new  String(s1);  3.if(s1 == s2)4.Sytstem.out.print("hello"));  5.if (s1.equals(s2))  6.Sytstem.out.print("world"));
    A: hello
    B: world
    C: helloworld
    D: 没有输出
  • B

    内容

    • 0

      以下代码共创建了几个对象?String s1=new String("hello");String s2=new String("hello");String s3=s1;String s4=s2; A: 2 B: 4 C: 1 D: 3

    • 1

      String s1="Hello";String s2="World";System.out.println(s2+s1);运行的结果是? A: HelloWorld B: Hello World C: WorldHello D: World Hello

    • 2

      执行下面代码后,将创建()个对象。String s1="hello";String s2=new String(s1); A: 0 B: 1 C: 2 D: 3

    • 3

      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!

    • 4

      【其它】写出并理解下列语句输出的结果 s = "hello" print(s[0]) print(s[4]) print(s[-1]) print(s[0:3]) print(s[0:4:2]) print(s[:]) print(s[:3]) print(s[::-1]) print(s[1:])