java笔试题(word版)

java笔试题(word版)

ID:33037239

大小:39.50 KB

页数:14页

时间:2019-02-19

java笔试题(word版)_第1页
java笔试题(word版)_第2页
java笔试题(word版)_第3页
java笔试题(word版)_第4页
java笔试题(word版)_第5页
java笔试题(word版)_第6页
java笔试题(word版)_第7页
java笔试题(word版)_第8页
java笔试题(word版)_第9页
java笔试题(word版)_第10页
资源描述:

《java笔试题(word版)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、1.Whatwillbetheoutputwhenyoucompileandexecutethefollowingprogram.publicclassBase{privatevoidtest(){System.out.println(6+6+"(Result)");}staticpublicvoidmain(String[]a){newBase().test();}}Selectmostappropriateanswer.A66(Result)B12(Result)CRuntimeError.Incompatibletypefor+.Can'tconvert

2、aninttoastring.DCompilationError.Incompatibletypefor+.Can'taddastringtoanint.解答:B考点:字符串与基本数据的链接1.如果第一个是字符串那么后续都按字符串进行处理2.如果第一个到第n个是基本数据,第n+1个是字符串,那么前n个数据都按加法计算,再与字符串链接2..Whatwillbetheoutputwhenyoucompileandexecutethefollowingprogram.Thesymbol’⌴’meansspace.1:publicclassBase{2:3:priva

3、tevoidtest(){4:5:StringaStr="⌴One⌴";6:StringbStr=aStr;7:aStr.toUpperCase();8:aStr.trim();9:System.out.println("["+aStr+","+bStr+"]");7:}8:9:staticpublicvoidmain(String[]a){10:newBase().test();11:}12:}Selectmostappropriateanswer.A[ONE,⌴One⌴]B[⌴One⌴,One]C[ONE,One]D[ONE,ONE]E[⌴One⌴,⌴On

4、e⌴]解答:E通过StringbStr=aStr;这句代码使bStr和aStr指向同一个地址空间。String类是定长字符串,调用一个字符串的方法以后会形成一个新的字符串。3.Java语言中,String类的indexOf()方法返回的类型是?A、Int16B、Int32C、intD、long解答:CindexOf方法的声明为:publicintindexOf(intch)返回指定字符在字符串中第一次出现的索引,如果未出现该字符,则返回-14..执行下列代码后,哪个结论是正确的String[]s=newString[10];A.s[9]为null;B.s[10

5、]为"";C.s[0]为未定义D.s.length为10解答:ADs是引用类型,s中的每一个成员都是引用类型,即String类型,String类型默认的值为null,s数组的长度为10。5.Given:publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?A.NULLB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownat

6、runtime.解答:Bnull应该小写6、Given:publicclassTest{publicstaticvoidmain(Stringargs[]){classFoo{publicinti=3;}Objecto=(Object)newFoo();Foofoo=(Foo)o;System.out.println(foo.i);}}Whatistheresult?A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“3”C.Compilationwillsucceedbut

7、theprogramwillthrowaClassCastExceptionatline6.D.CompilationwillsucceedbuttheprogramwillthrowaClassCastExceptionatline7.解答:B考点:局部内部类的使用局部内部类定义在方法中,作用域相当于局部变量的作用域7、Given:publicclassTest{publicstaticvoidmain(String[]args){Stringfoo=“blue”;Stringbar=foo;foo=“green”;System.out.println(ba

8、r);}}Whatistheresul

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。