网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
Giventhismethodinaclass:publicStringtoString(){StringBufferbuffer=newStringBuffer();buffer.append(?<?);buffer.append(this.name);buffer.append(?>?);returnbuffer.toString();}Whichistrue?()

A.ThiscodeisNOTthread-safe.

B.TheprogrammercanreplaceStringBufferwithStringBuilderwithnootherchanges.

C.ThiscodewillperformwellandconvertingthecodetouseStringBuilderwillnotenhancetheperformance.

D.Thiscodewillperformpoorly.Forbetterperformance,thecodeshouldberewritten:return“<“+this.name+“>”;


参考答案

更多 “ Giventhismethodinaclass:publicStringtoString(){StringBufferbuffer=newStringBuffer();buffer.append(??);buffer.append(this.name);buffer.append(??);returnbuffer.toString();}Whichistrue?() A.ThiscodeisNOTthread-safe.B.TheprogrammercanreplaceStringBufferwithStringBuilderwithnootherchanges.C.ThiscodewillperformwellandconvertingthecodetouseStringBuilderwillnotenhancetheperformance.D.Thiscodewillperformpoorly.Forbetterperformance,thecodeshouldberewritten:return““+this.name+“”; ” 相关考题
考题 publicclassPerson{2.privateStringname;3.publicPerson(Stringname){this.name=name;}4.publicbooleanequals(Personp){5.returnp.name.equals(this.name);6.}7.}Whichistrue?() A.TheequalsmethoddoesNOTproperlyoverridetheObject.equalsmethod.B.Compilationfailsbecausetheprivateattributep.namecannotbeaccessedinline5.C.Toworkcorrectlywithhash-baseddatastructures,thisclassmustalsoimplementthehashCodemethod.D.WhenaddingPersonobjectstoajava.util.Setcollection,theequalsmethodinline4willpreventduplicates.

考题 publicclassPerson{privatename;publicPerson(Stringname){this.name=name;}publicbooleanequals(Objecto){if(!oinstanceofPerson)returnfalse;Personp=(Person)o;returnp.name.equals(this.name);}}Whichistrue?() A.CompilationfailsbecausethehashCodemethodisnotoverridden.B.AHashSetcouldcontainmultiplePersonobjectswiththesamename.C.AllPersonobjectswillhavethesamehashcodebecausethehashCodemethodisnotoverridden.D.IfaHashSetcontainsmorethanonePersonobjectwithname=”Fred”,thenremovinganother person,alsowithname=”Fred”,willremovethemall.

考题 publicclassPerson{privatename;publicPerson(Stringname){this.name=name;}publicinthashCode(){return420;}}Whichistrue?() A.ThetimetofindthevaluefromHashMapwithaPersonkeydependsonthesizeofthemap.B.DeletingaPersonkeyfromaHashMapwilldeleteallmapentriesforallkeysoftypePerson.C.InsertingasecondPersonobjectintoaHashSetwillcausethefirstPersonobjecttoberemovedasaduplicate.D.ThetimetodeterminewhetheraPersonobjectiscontainedinaHashSetisconstantanddoesNOTdependonthesizeofthemap.

考题 本程序的功能是,根据用户输入的文件名,在相应的文件内容中查找匹配给定模式的字符串,并将这些字符串显示出来。模式串为“href="…"”。请填写横线处的内容。注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。import java.io.*;import java.util.regex.*;import javax.swing.*;public class Example2_10{public static void main(String [] argv){final String patternString ="href\\s*=\\s*(\"[^\"]*\"|[^\\s>])\\s*;String fileName ;try{System. out. print ( "请输入html 文件的文件名: ");InputStreamReader in = new InputStreamReader(System.in);BufferedReader imput = new BufferedReader(in);fileName = imput.readLine();if(fileName.equals(" "))return;StringBuffer buffer = new StringBuffer();File file = new File(fileName);FileInputStream readfile = new FileInputStream(file);for(int c = 0; (c = readfile.read()) != -1; )buffer.append((char)c);Pattern pattern = Pattern.compile(_____________ Pattern.CASE_INSENSITIVE);Matcher matcher =________;while (marcher. find ()){int start = matcher.start();int end = matcher.end();String match = buffer.substring(start, end);System.out.println (match);}}catch (Exception excption){System. out.println (excption. getMessage ());}System.exit(O);}}

考题 若有运算符:&gt;、一、&lt;&lt;、%、sizeof,则它们按优先级(由高至低)的正确排列顺序为( )。A.%、sizeof、&gt;、&lt;&lt;、=B.sizeof、%、&gt;、一、&lt;&lt;C.sizeof、&lt;&lt;、&gt;、%、=D.sizeof、%、&lt;&lt;、&gt;、=

考题 与表达式“BETWEEN50ANDl00”功能相同的表达式是( )。A.&gt;=50AND&lt;=100B.&gt;50AND&lt;100C.&lt;=500R&gt;=100D.IN(50,100)

考题 阅读以下说明和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);

考题 下列表达式结果为“真”的是A.2 #gt# 3 #and# 4 #gt# 2 ;B.2 #lt# 3 #and# 4 #lt# 2 ;C.2 #gt# 3 #and# 4 #lt# 2 ;D.2 #lt# 3 #and# 4 #gt# 2;

考题 1位数值比较器当输入A=0,B=1时?A.LT_L=1,GT_L=0,EQ_L=1B.LT_L=1,GT_L=1,EQ_L=0C.LT_L=0,GT_L=1,EQ_L=1D.LT_L=1,GT_L=0,EQ_L=0