资源描述:
《Java(10专)C卷答案及评分标准》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、济宁学院计算机科学系《Java程序设计》期末考试C参考答案及评分标准一、单项选择题(本大题共15,每小题2分,共30分)在每小题列出的四个备选项中只有一个是符合题目要求的,请将其代码填写在题后的括号内。错选、多选或未选均无分。12345678910BBDACCCACC1112131415BAABC二、填空1、编辑源程序、编译生成字节码、解释运行字节码2、Applet、MyApplet3、javac.exe、3、.class4、2、25、06、true、false7、抽象(abstract)方法、最终(final)方法济宁学院8、package MyPackage
2、; 应该在程序第一句。9、staticdoubleadditoryFee=0.1;10、单、多11、6三、程序结果(每空4分,共20分)1、s=50502、Hello!IloveJAVA.3、s=1804、a=60b=20c=305、1131416171四.编程题(共两大题,每小题10分,共20分)1、参考程序如下:publicclassSum{publicstaticvoidmain(Stringargs[]){doublesum=0.0;for(inti=1;i<=100;i++)sum+=1.0/(double)i;System.out.println
3、("sum="+sum);}}2、参考程序如下:classLinght{Privateintwatts;PrivateBooleanindicator;Linght(intwatts){this.watts=watts;}Light(intwatts,Booleanindicator){this.watts=watts;this.indicator=indicator;}济宁学院publicvoidswitchOn(){this.indicator=true;}publicvoidswitchOff(){this.indicator=false;}pulicvoi
4、dprintInfo()System.out.println(“watts=”+watts);System.out.println(“indicator=”+indicator);}}ClassTubeLightextendsLight{privateinttubLength;privateString;TubeLight(intwatts,inttubeLigth,Stringcolor){super(watts);this.tubeLigth=tubeLigth;this.color=color;}publicvoidprintinfo(){super.pri
5、ntinfo();System.out.println(“tubeLight=”+tubeLight);System.out.println(“color=”+color);}}ClassTest{publicstaticvoidmain(Stringarg[]){济宁学院TubeLightt1=newTubeLight(32,50,”白色”);T1.switchOn();T1.printinfo();}}3classPerson{Stringname;charsex;intage;publicPerson(Stringname,charsex,intage){t
6、his.name=name;this.sex=sex;this.age=age;}}classStudentextendsPerson{Stringno;Stringenter;Stringmajor;publicStudent(Stringname;charsex;intage,Stringno,Stringenter,Stringmajor){super(name,sex,age);this.no=no;济宁学院this.enter=enter;this.major=major;}publicStringtoString(){returnname+”,”+se
7、x+”,”+age+”,”+no+”,”+enter+”,”+major;}}ClassTeacharextendsPerson{Stringpro;Stringdepartment;PublicTeacher(Stringname,charsex,intage,Stringpro,Stringdepartment){Super(name,sex,age);This.pro=pro;This.department=department;}PublicStringtoString(){Returnname+”,”+sex+”,”+age+”,”+pro+”,”+de
8、partm