更多“给出下面的代码,则以下( )选项返回true。String s="hello";String t="hello";Char c[]={'h','e', ”相关问题
  • 第1题:

    以下选项中正确的语句组是( )。

    A.char s[]; s="HELLO!";

    B.char *s; s={"HELLO!"};

    C.char s[10]; s="HELLO!";

    D.char *s; s="HELLO!";


    正确答案:D

  • 第2题:

    给出下列的代码,则以下( )选项返回true。 String s="hello"; String t="hello": char c[]={'h','e','l','l','o',};

    A.s.equals(t);

    B.t.equals(c);

    C.s==t;

    D.t==c;


    正确答案:A

  • 第3题:

    【单选题】8.7 若有以下程序代码,则程序运行结果正确的是() public class DemoMain { public static void main(String []s){ String a = new String("hello"); String b = new String("hello"); String c = "hello"; String d = a; System.out.print((a==d)+" "+(a==b)+" "+(a==c)); } }

    A.true false true

    B.true false false

    C.true true false

    D.false true true


    错误推测法

  • 第4题:

    给出下列的代码则以下哪个选项返回true? String s = "hello" ; String s = "hello" ; char c[] = { 'h' ,'e','l','o'};

    A.s.equals(t);

    B.t.equals(c);

    C.s = =t

    D.t = = c;


    正确答案:A
    解析:==操作符比较的是操作符两端的操作数是否是同一个对象,String的equals()方法比较的是两个String对象的内内容是否一样。s.equals(1)方法比较字符串s与字符串t中的内容是否一致,所以返回true。

  • 第5题:

    给出下面程序: public class ex51 { public static void main(String[] args) { String s = "hello"; String t = "hello"; char c[] = {'h', 'e', '1', '1', 'o'}; System. out. println (______) } } 在程序的横线处填入下列______选项后,程序输出的结果是true。

    A.t.equals(c)

    B.s.equals?

    C.s == t

    D.t == c


    正确答案:C