1 / 12
文档名称:

JAVA实验三.doc

格式:doc   大小:145KB   页数:12页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

JAVA实验三.doc

上传人:xgs758698 2019/5/18 文件大小:145 KB

下载得到文件列表

JAVA实验三.doc

相关文档

文档介绍

文档介绍:学院: 计算机科学与信息学院专业:网络工程班级:、接口的使用实验目的1、学会JAVA小程序的设计,并在JCREATOR上运行,发现小问题。2、学会通过接口实现多态。实验要求根据老师给的程序,在JCREATOR上运行并分析。实验原理正确处理JAVA实验程序,并进行分解。JAVA中可用接口来实现多态。实验仪器JCREATOR实验步骤按题目顺序对程序进行运行。根据题目要求编程。对结果进行分析,若错误分析原因。运行书中例5-5得实验结果并进行分析。实验内容一、1、Givethefollowingcode:lassExample{publicstaticvoidmain(Stringargs[]){intl=0;do{(“Doingitforlis:”+l);}while(--l>0)(“Finish”);}}Whichwellbeoutput:? 2、pletedmethod:1)2){if(unsafe()){//dosomething…}3}elseif(safe()){//dotheother…}4}}Themethodunsafe()wellthrowanIOException,pletesthemethodofdeclarationwhenaddedatlineone?()()()()()throwsException3、  Givethefollowingmethod:publicvoidexample(){try{unsafe();(“Test1”);}catch(SafeExceptione){(“Test2”);}finally{(“Test3”);}(“Test4”);Whichwilldisplayifmethodunsafe()runnormally?、  ,pilation:1)classSubClassextendsBaseClass{2}}3)classBaseClass(){4}Stringstr;5}publicBaseClass(){6}(“ok”);}7}publicBaseClass(Strings){8}str=s;}}9)lassExample{10}publicvoidmethod(){11}SubClasss=newSubClass(“hello”);12}BaseClassb=newBaseClass(“world”);13}}14}}Whichlinewouldbecausetheerror?、  Givethefollowingjavasourcefragement://lassInteresting{//dosomething}WhichstatementiscorrectlyJavasyntaxatpointx?.*;={//dootherthing…}{//dosomething…}6、  Givethefollowingclassdefinationinseparatesourcefiles:lassExample{publicExample(){//dosomething}protectedExample(inti){//dosomething}protectedvoidmethod(){//dosomething}}lassHelloextendsExample{//memberm