下列语句输出结果为( )。public class test{public static void main(String args []){String s1=new String("How");String s2=new String("How");System.out. println(!(s1 ==s2));}
A: false
B: true
C: 1
D: 0
A: false
B: true
C: 1
D: 0
举一反三
- public class Test { public static void main(String[] args) { String s1 = "abc"; String s2 = new String ("abc"); System.out.println(s1 == s2); } } 程序运行结果是
- 下列程序段: String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); 的结果为 A: false B: true C: 1 D: 0
- 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!
- 下列程序的输出结果是( ) class StringDemo{ public static void main(String[] args){ String s1 = “a”; String s2 = “b”; show(s1,s2); System.out.println(s1+s2); } public static void show(String s1,String s2){ s1 = s1 +“q”; s2 = s2 + s1; } } A: a B: aq C: aqbaq D: aqaq
- 下面程序代码运行结果为( )。 import java.awt.*; public class Test { public static void main (String args[]) { String s1="a+b+c"; String s2="+"; int i=s1.lastIndexOf (s2); System.out.println(i); } } A: 0 B: 1 C: 2 D: 3