欢迎来到天天文库
浏览记录
ID:37923332
大小:52.50 KB
页数:4页
时间:2019-06-02
《Java 基础找错面试题(2)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、12.代码查错题:publicstaticvoidmain(String[]args){intx=3;inty=3;if(x.equals(y)){System.out.println("两者相等!");}}13.代码查错题:publicstaticvoidmain(String[]args){intx;System.out.println("x="+x);}14.代码查错题:publicstaticvoidmain(String[]args){OutputStreamos=null; try{ os=newOutputStream();
2、 //Dosomethingwithoshere. }catch(Exceptione){e.printStackTrace(); if(os!=null) os.close(); }}}15.代码查错题:publicstaticvoidmain(String[]args){try{//Niftycodehere}catch(Exceptione){//throwe;e.printStackTrace();}finally{//Cleanupcodehere}}16.控制台打印出的结果是:publicclassJtest{intm=1;
3、inti=3;voidJtest(){m=2;i=4;}publicstaticvoidmain(String[]args){Jtestapp=newJtest();System.out.println(app.m+","+app.i);}}17.控制台打印出的结果是:publicclassTest{publicstaticvoidmain(String[]args){inta=99;oper(a);System.out.print(a);}staticvoidoper(intb){b=b+100;}}18.控制台打印出的结果是:publicc
4、lassTest{publicstaticvoidmain(String[]args){Stringa=newString("A");Stringb=newString("B");oper(a,b);System.out.print(a+","+b);}staticvoidoper(Stringc,Stringd){c.concat("B");d=c;}}19.控制台打印出的结果是:publicclassTest{publicstaticvoidmain(String[]args){StringBuffera=newStringBuffer("
5、A");StringBufferb=newStringBuffer("B");oper(a,b);}staticvoidoper(StringBufferc,StringBufferd){c.append("Z");d=c;System.out.print("d:"+d);}}20.控制台打印出的结果是:publicclassUserGoalBoardDaoImplTest{staticinta;static{a++;intx=a;System.out.println("x="+x);}publicUserGoalBoardDaoImplTes
6、t(){a++;inty=a;System.out.println("y="+y);}publicstaticvoidmain(String[]args){newUserGoalBoardDaoImplTest();newUserGoalBoardDaoImplTest();}}21.写出一个声明长度为5的Char类型数组对象的代码:22.写出一个声明只能存放float类型的list对象代码:23.写出定义一个私有常量的代码:24.控制台打印出的结果是:publicstaticvoidmain(String[]args){System.out.
7、println(Math.round(10.5));System.out.println(Math.round(-10.5));}25.运行下面代码会出现什么结果?(简单描述即可)publicstaticvoidmain(String[]args){while(true){System.out.println("输出日志");}}26.运行下面代码会出现什么结果?(简单描述即可)publicstaticvoidmain(String[]args){Stringstr=null;System.out.println(str.toString())
8、;}27.控制台打印出的结果是:publicstaticvoidmain(String[]args){intx=3;System.out.printl
此文档下载收益归作者所有