欢迎来到天天文库
浏览记录
ID:48144034
大小:166.00 KB
页数:38页
时间:2020-01-21
《java200道选择题已做.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.一.选择题(234)1.下面中哪两个可以在A的子类中使用:(A,C)classA{protectedintmethod1(inta,intb){return0;}}A.publicintmethod1(inta,intb){return0;}B.privateintmethod1(inta,intb){return0;}C.privateintmethod1(inta,longb){return0;}D.publicshortmethod1(inta,intb){return0;}2.Abstractmethod
2、cannotbestatic.TrueorFalse?(A)A.TrueB.False3.Whatwillbetheoutputwhenyoucompileandexecutethefollowingprogram.classBase{voidtest(){System.out.println("Base.test()");}}publicclassChildextendsBase{voidtest(){System.out.println("Child.test()");}staticpublicvoidmain
3、(String[]a){ChildanObj=newChild();BasebaseObj=(Base)anObj;baseObj.test();}}Selectmostappropriateanswer.AA.Child.test()Base.test()B.Base.test()Child.test()C.Base.test()D.Child.test()4.Whatwillbetheoutputwhenyoucompileandexecutethefollowingprogram.classBase{stat
4、icvoidtest(){System.out.println("Base.test()");}}..publicclassChildextendsBase{voidtest(){System.out.println("Child.test()");Base.test();//Calltheparentmethod}staticpublicvoidmain(String[]a){newChild().test();}}Selectmostappropriateanswer.CA.Child.test()Base.t
5、est()B.Child.test()Child.test()C.Compilationerror.CannotoverrideastaticmethodbyaninstancemethodD.Runtimeerror.Cannotoverrideastaticmethodbyaninstancemethod5.Whatwillbetheoutputwhenyoucompileandexecutethefollowingprogram.publicclassBase{privatevoidtest(){System
6、.out.println(6+6+"(Result)");}staticpublicvoidmain(String[]a){newBase().test();}}Selectmostappropriateanswer.BA.66(Result)B.12(Result)C.RuntimeError.Incompatibletypefor+.Can'tconvertaninttoastring.D.CompilationError.Incompatibletypefor+.Can'taddastringtoanint.
7、6..Whatwillbetheoutputwhenyoucompileandexecutethefollowingprogram.Thesymbol’.’meansspace.publicclassBase{privatevoidtest(){StringaStr=".One.";StringbStr=aStr;aStr.toUpperCase();aStr.trim();System.out.println("["+aStr+","+bStr+"]");}staticpublicvoidmain(String[
8、]a){newBase().test();}..}Selectmostappropriateanswer.EA.[ONE,.One.]B.[.One.,One]C.[ONE,One]D.[ONE,ONE]E.[.One.,.One.]7.下面关于变量及其范围的陈述哪些是不正确的(B):A.实例变量是类的成员变量)B.实例变量用关键字static声明(用sta
此文档下载收益归作者所有