对于以下代码,表达式的值为true的是 String str1="java"; String str2="java"; String str3=new String("java"); StringBuffer str4=new StringBuffer("java");A.str1==str2B.str1==str4C.str1==str3D.str3==str4

对于以下代码,表达式的值为true的是 String str1="java"; String str2="java"; String str3=new String("java"); StringBuffer str4=new StringBuffer("java");

A.str1==str2

B.str1==str4

C.str1==str3

D.str3==str4


参考答案和解析
eval('1')==int(1)

相关考题:

阅读以下说明和java代码,将应填入(n)处的字句写在对应栏内。[说明]本程序中预设了若干个用户名和口令。用户输入正确的用户名后,可以查找对应的口令,一旦输入结束标记“end”,程序结束。[Java代码]import java. io. *:public class User {public String user;public Siring pass;public User() { }public User( String u,String p) {user=u;pass=p;}public String (1) () { return this. user; }public String (2) () { return this. pass; }public static void main(String[] args) {User ua[]={new User("Li","123456"), new User("wang","654321"),new User("Song","666666")};while(true) {InputStreamReader reader = new InputStreamReader(System. in);BufferedReader inpul = new BnfferedReader(reader);System. out. print("Enter your name:");String name = null;try { name = input. readLine();}catch (IOException ex) {}if((3)) break;int i;for (i=0;i<3;i++) {if (name. equals(ua[i]. getUser())){System. out. println("密码:"+ua[i].getPass());(4);}}if ((5)) System. out. println("该用户不存在!");}}}

在Java中,字符串由java.lang.String和( )定义。A.java. lang. StringCharB.java. lang.StringBufferC.java. io. StringCharD.java. io. StringBuffer

下列Java表达式,错误的是()。 A.long j=8888;B.Stringstr=String("bb");C.charc=74;D.intk=new String("aa");

设有语句:char str1[]="string",str2[8],*str3,*str4="string";,则下列对库函数strcpy调用不正确的是A.strcpy(str1,"Hello1");B.strcpy(str2,"Hello2");C.strcpy(str3,"Hello3");D.strcpy(str4,"Hell04");

有如下applet代码:import java.applet.*;import java.awt.*;public class MyApplet extends Applet{AA s;public void int(){s = new AA("Hello!", "I love JAVA.");}public void paint(Graphics g){g.drawString(s.toString(), 30, 50);}}class AA{String s1;String s2;AA(String str1, String str2){s1 = str1;s2 - str2;}public String toString(){return s1 + s2;}}运行后,窗口上将会出现什么,选择一个正确答案______。A.Hello!B.I love JAVA.C.Hello! I love JAVA.D.什么都没有

设有以下语句: char str1[]="string",str2[8],*str3,*str4=="string; 则______不是对库函数的正确调用。A.strcpy(str1,"HELLO1");B.strcpy(str2,"HELLO2");C.strcpy(str3,"HELLO3");D.strcpy(str4,"HELLO4")

在Java中,字符串由java.lang.String和( )定义。A.java.lang.StringCharB.java.lang.StringBufferC.java.io.StringCharD.java.io.StringBuffer

Youneedtocreateaservletfilterthatstoresallrequestheaderstoadatabaseforallrequeststothewebapplication’shomepage/index.jsp.WhichHttpServletRequestmethodallowsyoutoretrievealloftherequestheaders?()A.String[]getHeaderNames()B.String[]getRequestHeaders()C.java.util.IteratorgetHeaderNames()D.java.util.IteratorgetRequestHeaders()E.java.util.EnumerationgetHeaderNames()

Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object?() A.When using versions of Java technology earlier than 5.0.B.When sharing a StringBuffer among multiple threads.C.When using the java.io class StringBufferInputStream.D.When you plan to reuse the StringBuffer to build more than one string.

下面代码的运行结果是( )。 public class ConcatTest { public static void main (String[ ] args) { String str1 = "abc"; String str2 = "ABC"; String str3 = str1. coneat(str2); System. out. println(str3); } }A.abcB.ABCC.abcABCD.ABCabc

下列关于字符串的叙述错误的是( )。A.创建String类的字符串对象后,字符串所代表的内容根据情况可改变B.字符串可以使用java.lang.String和java.lang.StringBuffer来定义C.StringBuffer用来处理长度可变的字符串D.在Java语言中,字符串是作为对象来处理的

下面哪些代码在Java语言中是合法的? ( )A.string A="abcdefg"; A-="cde";B.string A="abcdefg"; A+="cde";C.Integer J=new Integer(27); J-=7;D.Integer J=new Integer(27); J--;

阅读以下说明和Java代码,回答问题[说明]在某些系统中,存在非常复杂的对象,可以采用循序渐进的方式进行组合将小对象组合,成复杂的对象。以下实例展示了Builder(生成器)模式。该实例用来建立“文件”,文件内容包括:一个标题、一串字符以及一些有项目符号的项目。Builder类规定组成文件的方法,Director类利用这个方法产生一份具体的文件。图6-1显示了各个类间的关系。以下是Java语言实现,能够正确编译通过。[Java代码]//Builder. java文件public (1) class Builder {public abstract void makeTitle(String title);public abstract void makeString(String str);public abstract void makeItems(String[] items);public abstract Object getResult();}//Director. java文件public class Director{private (2) builder;public Director(Builder builder){this. builder = builder;}public Object construct(){builder.makeTitle("Greeting");builder.makeString("从早上到白天结束");builder.makeItems(new String[]{"早安", "午安",});builder.makeString("到了晚上");builder.makeItems(new String[]("晚安", "好梦",});return builder.getResult();}}//TextBuilder.java文件public class TextBuilder (3) Builder{private StringBuffer buffer = new StringBuffer();public void makeTitle(String title){buffer.append("『" + title + "』"\n\n");}public void makeString(String str){buffer.append('■' + str + "\n\n ");}public void makeItems(String[] items){for(int i = 0; i (4) ; i++){buffer.append('·' + items[i] + "\n");}buffer.append("\n");}public Object getResult(){return buffer.toString();}}//Main.java文件public class Main {public static void main(String[] args) {Director director = new Director(new TextBuilder());String result = (String)director. (5) ;System.out.println(result);

设有以下语句:  char str1[]= “string”,str2[8],*str3,*str4= “ string”;      则不能对库函数strcpy(复制字符串)的正确调用的是()A、strepy(str1,“HELLO1”);B、strepy(str2,“HELL02”);C、strcpy(str3, “HELL03”)D、strcpy(str4, “HELLO4”);

public class EqTest{()  Public static void main(String args[])  EqTest e=new EqTest(); }  EqTest(){  String s=”Java”; String s2=”java”;  //在这儿放置测试代码  {Systrm.out.println(“相等”);  Else{System.out.println(“不相等”)} }  } 在上面的java代码的注释行位置,放置()测试代码能输出“相等”结果 A、if(s==s2)B、if(s.equals(s2))C、if(s.equalsIgnoreCase(s2))D、if(s.noCaseMatch(s2))

Whichtwo scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object?()A、When using versions of Java technology earlier than 5.0.B、When sharing a StringBuffer among multiple threads.C、When using the java.io class StringBufferInputStream.D、When you plan to reuse the StringBuffer to build more than one string.E、Enitiation of separate design processes to the separation of users

//point X  public class foo (  public static void main (String[]args) throws Exception {  printWriter out = new PrintWriter (new  java.io.outputStreamWriter (System.out), true;  out.printIn(“Hello”);  }  )   Which statement at PointX on line 1 allows this code to compile and run?()  A、 Import java.io.PrintWriter;B、 Include java.io.PrintWriter;C、 Import java.io.OutputStreamWriter;D、 Include java.io.OutputStreamWriter;E、 No statement is needed.

Public class test (  Public static void stringReplace (String text)  (  Text = text.replace (‘j’ , ‘i’);  )  public static void bufferReplace (StringBuffer text)  (  text = text.append (“C”)  )   public static void main (String args[]}  (  String textString = new String (“java”);  StringBuffer text BufferString = new StringBuffer (“java”);  stringReplace (textString);  BufferReplace (textBuffer);  System.out.printLn (textString + textBuffer);  )  )   What is the output?()

使用String s1=new String("Java");String s2=new String("Java")创建两个字符串时,s1,s2使用不同的内存空间

public class Test {  public static void main (String[]args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.printIn(“baz = ” + baz);  }  }  And the output:  Baz = 2  Which command line invocation will produce the output?()  A、 Java Test 2222B、 Java Test 1 2 3 4C、 Java Test 4 2 4 2D、 Java Test 4 3 2 1

//point X  public class foo { public static void main (String[]args) throws Exception {  java.io.printWriter out = new java.io.PrintWriter {  new java.io.outputStreamWriter (System.out), true;  out.printIn(“Hello”); }  }  }   Which statement at PointX on line 1 allows this code to compile and run?()  A、 Import java.io.*;B、 Include java.io.*;C、 Import java.io.PrintWriter;D、 Include java.io.PrintWriter;E、 No statement is needed.

多选题Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object?()AWhen using versions of Java technology earlier than 5.0.BWhen sharing a StringBuffer among multiple threads.CWhen using the java.io class StringBufferInputStream.DWhen you plan to reuse the StringBuffer to build more than one string.

单选题public class EqTest{()  Public static void main(String args[])  EqTest e=new EqTest(); }  EqTest(){  String s=”Java”; String s2=”java”;  //在这儿放置测试代码  {Systrm.out.println(“相等”);  Else{System.out.println(“不相等”)} }  } 在上面的java代码的注释行位置,放置()测试代码能输出“相等”结果Aif(s==s2)Bif(s.equals(s2))Cif(s.equalsIgnoreCase(s2))Dif(s.noCaseMatch(s2))

单选题//point X  public class foo { public static void main (String[]args) throws Exception {  java.io.printWriter out = new java.io.PrintWriter {  new java.io.outputStreamWriter (System.out), true;  out.printIn(“Hello”); }  }  }   Which statement at PointX on line 1 allows this code to compile and run?()A Import java.io.*;B Include java.io.*;C Import java.io.PrintWriter;D Include java.io.PrintWriter;E No statement is needed.

填空题Public class test (    Public static void stringReplace (String text) (    Text = text.replace („j„ , „i„);    )      public static void bufferReplace (StringBuffer text) (    text = text.append (“C”)   )      public static void main (String args ){  String textString = new String (“java”);    StringBuffer text BufferString = new StringBuffer (“java”);      stringReplace (textString);    BufferReplace (textBuffer);      System.out.printIn (textString + textBuffer);    }   )   What is the output?()

单选题public class Test {   public static void replaceJ(string text) {   text.replace (‘j‘, ‘l‘);   }   public static void main(String args) {   string text = new String (“java”)   replaceJ(text);   system.out.printIn(text);   }   }   What is the result?()A The program prints “lava”B The program prints “java”C An error at line 7 causes compilation to fail.D Compilation succeeds but the program throws an exception.

判断题使用String s1=new String("Java");String s2=new String("Java")创建两个字符串时,s1,s2使用不同的内存空间A对B错

单选题若有定义语句:char str1[] = "string", str2[8], *str3, str4[10] = "string";库函数strcpy的功能是复制字符串,以下选项中错误的函数调用是(  )。Astrcpy(str3, "HELLO!");Bstrcpy(str2, "HELLO!");Cstrcpy(str1, "HELLO!");Dstrcpy(str4, "HELLO!");