java高级编程计科061-20910第一学期-c_第1页
java高级编程计科061-20910第一学期-c_第2页
java高级编程计科061-20910第一学期-c_第3页
java高级编程计科061-20910第一学期-c_第4页
java高级编程计科061-20910第一学期-c_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、。装。订。线。2009 年2010 年第一学期Java 高级编程期末试题C 卷时间共 120 分钟一、单项选择题(每题 2 分,共 20 分)Which is valid returnType for methodA in line 2? (public class ReturnIt)2)3)4)5) AreturnType methodA(byte x, double y) return (double)x/y*2;B shortC floatD doublet y=ax3+8, which of the following are correct Java s2.Givenements f

2、or this equation?A y = a * ( x * x *x )+8; B y = a * x * x *( x +8);C y = ( a * x )* x *( x +8 ); D y = a * x * ( x *x +8 );3When throwing an exception, which keyword should be used ()A transientB finallyC throwD sic4.public class ConstOver public ConstOver(x,y,z)whiethod overload the ConstOver cons

3、tructor (A.ConstOver()B.protectedConstOver()C. public Object ConstOver(x,y,z)D.public void ConstOver(byte x, byte y, byte z)5. Whicherface is implemented by classes HttpServlet and GenericServlet?()AServletB HttpServletRequestC HttpServletResponseD ServletException6. We will create an instance of cl

4、ass ArrayList which extends theerface List, then which of thefollowings is right?()A ArrayList myList=new Object(); B List myList=new ArrayList();C ArrayList myList=new List(); D List myList=new List();得分阅卷人题 号一二三总分得 分阅卷人7. What is is a relation ()A. publicerface Colorpublic class Shprivate Color co

5、lor;B.erface Componentclass Container implements Component private Component children;C.public class Speciespublic class Animalprivate Species species;D.erface Aerface Berface C implements A,B8. After Execution, what are the value for i and j? ( i=1,j=10;doif(i+-j) continue;while(i= 0 & h = 0 & m =

6、0 & s 60)?s:0);/ get hour valuepublicgetHour()return hour;/ get minute valuepublicgetMinute()return minute;/ get second valuepublicgetSecond()return second; / end class Time22. Please use algorithm sort to order the elements of a List in descending order./ Using algorithm sort.(15 分)import import im

7、port publicjava.util.List; java.util.Arrays; java.util.Collections; class SortAlgorithmnprivate sicfinal String suits = Diamonds, Clubs, Spades ;array suits elements in descending order Hearts,/ sort and prpublic void sort_prElements() / end method sort_pr / end class SortAlgorithmnElements3. Roll a

8、 six-sided die 6000 times and count the roll value 1-6. Please comments. (15 分)import java.util.Random;public class RollDiepublic sic void main( String args )Random randomNumbers = new Random(); / random number generator frequency1 = 0; / count of 1s rolledfrequency2 = 0; / count of 2s rolled freque

9、ncy3 = 0; / count of 3s rolled frequency4 = 0; / count of 4s rolled frequency5 = 0; / count of 5s rolled frequency6 = 0; / count of 6s rolled face; / stores most recently rolled value/ summarize results of 6000 rolls of a dieplish the program according to thefor (roll = 1; roll = 6000; roll+ ) / end

10、 forSystem.out.pr System.out.prln( FacetFrequency ); / output headersf( 1t%dn2t%dn3t%dn4t%dn5t%dn6t%dn,frequency1, frequency2, frequency3, frequency4, frequency5, frequency6 ); / end main / end class RollDie4. Class GradeBook represents a grade book used by a professor to store andyze a set of stude

11、nt(15 分)grades.grades. Pleaseplish the define of methods according to the comments./ GradeBook.java, Grade book public class GradeBookprivate String courseName;using an array to store test/ name of course this GradeBook represents/ array of student gradesprivategrades;/ two-argument constructor init

12、ializes courseName and grades arraypublic GradeBook( String name,courseName = name; grades = gradesArray;gradesArray )/ method to set the course namepublic void setCourseName( String name )courseName = name; / store the course name/ method to retrieve the course name public String getCourseName()return courseName;/ perform various operationson the datapublic void pro/ call method System.out.prsGrades()getAverage to f( nClasscalculate the average gradeaverage and getis %.2fn, um%dnHighestgetAverage() );/ call methods getMinimumSystem.out.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论