欢迎来到天天文库
浏览记录
ID:47265065
大小:134.50 KB
页数:20页
时间:2019-09-01
《北京东方国信JAVA面试题 -答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、PartⅠ(每题1分)1)Whichofthefollowinglineswillcompilewithoutwarningorerror?Selectallvalidanswers.aea)floatf=0;b)charc="0";c)byteb=157;d)booleanf=null;e)inti=10;2)Whatarethevalidtypesforthegivenvariablei?cpublicclassBase{privatevoidtest(){//i=1;switch(i){}}staticpublicvoidmain(String[]a){newBase().tes
2、t();}}Selectmostappropriateanswer.a)char,intb)boolean,byte,char,short,intc)byte,char,short,intd)byte,char,short,int,longe)Onlyint3)Whatisthecorrectwayofdeclaratingmain()sothattheprogarmcanbecompiledandexecutedusingthisentrypoint.abcfa)staticpublicvoidmain(String[]args)b)staticpublicvoidmain(Stri
3、nga[])c)publicstaticvoidmain(String[]a)d)staticvoidpublicmain(String[]a)e)publicvoidmain(String[]a)f)staticpublicvoidmain(chararg[][])201)Whatwillbeoutputiftheprogramisexecutedasbelowjava-DOne-DTwo-DThreeSamplepublicclassSample{publicstaticvoidmain(Stringargv[]){System.out.println(argv[2])}}Sele
4、ctmostappropriateanswer.ba)Oneb)Twoc)Threed)Exceptionraised:"java.lang.ArrayIndexOutOfBoundsException:2"e)NonePartⅡ(每题1分)2)Abstractmethodcannotbestatic.TrueorFalse?truea)Trueb)False3)Whatwillbetheoutputwhenyoucompileandexecutethefollowingprogram.d////////////////////////////////////////////class
5、Base{voidtest(){System.out.println("Base.test()");}}////////////////////////////////////////////publicclassChildextendsBase{voidtest(){System.out.println("Child.test()");}staticpublicvoidmain(String[]a){ChildanObj=newChild();BasebaseObj=(Base)anObj;20//Baseb=newChild();//b.test();baseObj.test();
6、}}Selectmostappropriateanswer.a)Child.test()Base.test()b)Base.test()Child.test()c)Base.test()d)Child.test()1)Whatwillbetheoutputwhenyoucompileandexecutethefollowingprogram.C////////////////////////////////////////////classBase{staticvoidtest(){System.out.println("Base.test()");}}////////////////
7、////////////////////////////publicclassChildextendsBase{voidtest(){System.out.println("Child.test()");Base.test();//Calltheparentmethod}staticpublicvoidmain(String[]a){newChild().test();}}Selectmostappropriateanswer.a)Child.
此文档下载收益归作者所有