《Java面向对象程序设计》科目考试卷及答案.doc

上传人:wux****ua 文档编号:8438141 上传时间:2020-03-29 格式:DOC 页数:13 大小:166KB
返回 下载 相关 举报
《Java面向对象程序设计》科目考试卷及答案.doc_第1页
第1页 / 共13页
《Java面向对象程序设计》科目考试卷及答案.doc_第2页
第2页 / 共13页
《Java面向对象程序设计》科目考试卷及答案.doc_第3页
第3页 / 共13页
点击查看更多>>
资源描述
班级考号姓名装订线安徽财贸职业学院20112012学年第二学期Java面向对象程序设计期末试卷(B卷)适用班级:软件1101 题号一二三四总分得分得分评卷人一、单选题(每小题1分,共30分)1在MyEclipse中,( )视图可以将项目中包含的文件及层次结构展示出来。A) PackageB)DeclarationC)NavigatorD) Console2下列标识符中,正确的是( )。A)classB) 123_rrC) _lei D) test&123下列的( )选项可以正确用以表示八进制值8。A)0x8 B)0x10 C)08 D)0104以下哪个不是Java的原始数据类型( )A) int B) booleanC) float D) Char5下列有关Java布尔类型的描述中,正确的是( )A)一种基本的数据类型,它的类型名称为booleanB)用int表示类型C)其值可以赋给int类型的变量D)有两个值,1代表真,0代表假6在Java中,不属于整数类型变量的是( ) A) doubleB) longC) intD) byte7以下do-while语句构成的循环执行次数是( )。int k=0;do +k ;while(k1);A) 一次也不执行B) 执行1次C) 无限次D) 有语法错误,不能执行8表达式(1/01)& (12=0) 的值为( )。A) true B) false C) 0 D) 运行时抛出异常9以下( )表达式不可以作为循环条件A) i=5B )i3 C) count=i D) bEqual=str.equals(q)10下列数组初始化正确的是( )A) int score5 = 90,12,34,77,56;B) int5 score = new int;C) int score = new int590,12,34,77,56;D) int score = new int90,12,34,77,56;11若有定义:byte x=11,22,33,-66;其中0k3,则对x数组元素错误的引用是( )A) x5-3B) xkC) xk+5 D) x012以下代码的输出结果是()。public static void main(String args) for(int i=1;i0;29请问所有的异常类皆继承哪一个类?( )。A)java.io.ExceptionB)java.lang.ThrowableC)java.lang.ExceptionD)java.lang.Error30对于catch子句的排列,下列哪种是正确的( ) A)父类在先,子类在后 B)子类在先,父类在后 C)有继承关系的异常不能在同一个try程序段内 D)先有子类,其他如何排列都无关得分评卷人二、填空题(每空2分,共20分)1Java有_、_和JavaME三个版本。2Java 源程序文件编译后产生的文件称为_文件,其扩展名为_。3面向对象编程的三大特性是_、_和多态。4_方法是一种仅有方法头,没有具体方法体和操作实现的方法,该方法必须在抽象类之中定义。_方法是不能被当前类的子类重新定义的方法。5子类必须通过_关键字调用父类有参数的构造函数。6在Java程序中,通过类的定义只能实现单重继承,但通过_ 的定义可以实现多重继承关系。得分评卷人三、阅读理解题(每题4分,共20分)1下列程序段的运行结果为_。int a=1;while(a5)switch(a)case 0:case 3:a=a+1;case 1:case 2:a=a+2;System.out.print(a);2下列程序段的运行结果为_。class test1 public static void main(String args) int y,x=1,total=0; while(x=3) y=x*x; System.out.println(y); total+=y; +x; System.out.println(total is +total); 3下列程序段的运行结果为_。class Q1 public static void main(String args ) double d=10; Dec dec=new Dec( ); dec.decrement(d); System.out.println(d); class Dec public void decrement(double decMe) decMe = decMe -5; 4下列程序段的运行结果为_。 public class abc public static void main(String args ) SubSubClass x = new SubSubClass(10 , 20 , 30); x.show(); class SuperClass int a,b; SuperClass(int aa , int bb) a=aa; b=bb; void show( ) System.out.println(a=+a+nb=+b); class SubClass extends SuperClass int c; SubClass(int aa,int bb,int cc) super(aa,bb); c=cc; class SubSubClass extends SubClass int a; SubSubClass(int aa,int bb,int cc) super(aa,bb,cc); a=aa+bb+cc; void show() System.out.println(a=+a+nb=+b+nc=+c); 5下列程序段的运行结果为_。public class Test public static void foo(int i) try if(i=1) throw new Exception(); System.out.print(1); catch(Exception e) System.out.print(2); finally System.out.print(3); System.out.print(4); public static void main(String args) foo(1); 得分评卷人四、编程题(共30分)1(每空3分,共9分)分析下列程序,把程序补充完整。class point /定义坐标类 private int x,y; public point(int a,int b)x=a; y=b;class rec _【1】_ /定义长方形类int length,width;public rec(int a1,int b1,int l,int w) _【2】_; length=l;width=w;class testpublic static void main(String args) /定义名为r1的对象同时初始化坐标为0,0,长度为10,宽度为20_【3】_;2(7分)将一组乱序的字符进行升序和降序排列,并分别输出。输出格式如图1所示。图13(14分)汽车租赁公司出租多种车辆,车型和租金情况如下表所示。编写程序实现租赁价格的计算。轿车客车(金杯、金龙)车型别克商务舱GL8宝马550i别克林荫大道16座日租费(元/天)6005003008001500具体要求:车辆分为轿车和客车两大类,它们都继承自抽象类MotoVehicle,并实现其抽象方法calRent()。请根据下面给出的类图分别创建三个类,并在测试类TestRent中实现车辆的租赁。租赁过程如图2所示。Car-type:String+Car(no,brand,type)+getType():String+ calRent():intBus-seatCount:int+Bus(no,brand,seatCount)+getSeatCount ():String+calRent():intMotoVehicle-no:String-brand:String+ MotoVehicle ()+MotoVehicle (no,brand)+getNo():String+getBrand():String+calRent():int图2 安徽财贸职业学院20112012学年第二学期班级考号姓名装订线Java面向对象程序设计期末试卷答题卡(B卷)适用班级:软件1101题号一二三四总分得分得分评卷人一、单选题(每小题1分,共30分)123456789101112131415161718192021222324252627282930得分评卷人二、填空题(每空2分,共20分)1_ _2_ _3_ _4_ _5_ 6_得分评卷人三、阅读理解题(每题4分,共20分)1_ 2_3_ 4_5_得分评卷人四、编程题(共30分)1(每空3分,共9分)【1】_ 【2】_【3】_2(7分)3(14分)安徽财贸职业学院20112012学年度第二学期Java面向对象程序设计期末试卷答案(B卷)适用班级:软件1101一、单选题12345678910CCDDAABBAD11121314151617181920CDBACCBCAA21222324252627282930DDDDBCDCCB二、填空题 1JavaSE JavaeE2字节码 .class3封装 继承4抽象(或abstract) final5super6接口三、阅读理解题16 310.021 4a=60 4 b=20 9 c=30 Totle is 14 5234四、编程题1【1】entends Point 【2】super(a1,b1) 【3】Rec r1=new Rec(0,0,10,20)2import java.util.Arrays;public class CharsSort public static void main(String args) char chars = new chara,c,u,b,e,p,f,z; System.out.print(原字符序列:); for(int i = 0; i chars.length; i+) System.out.print(charsi + ); Arrays.sort(chars);/对数组进行升序排序 System.out.print(n升序排序后:); for(int i = 0; i = 0; i-) System.out.print(charsi + ); 3public abstract class MotoVehicle private String no;/ 汽车牌号 private String brand;/ 汽车品牌 public MotoVehicle() public MotoVehicle(String no, String brand) this.no = no; this.brand = brand; public String getNo() return no; public String getBrand() return brand; public abstract int calRent(int days); public final class Car extends MotoVehicle private String type;/ 汽车型号public Car() public Car(String no, String brand, String type) super(no, brand); this.type = type;public String getType() return type;public void setType(String type) this.type = type;public int calRent(int days) if (1.equals(type) / 代表550i return days * 500; else if (2.equals(type) / 2代表商务舱GL8 return 600 * days; else return 300 * days; public final class Bus extends MotoVehicle private int seatCount;/ 座位数 public Bus() public Bus(String no, String brand, int seatCount) super(no, brand); this.seatCount = seatCount; public int getSeatCount() return seatCount; public void setSeatCount(int seatCount) this.seatCount = seatCount; public int calRent(int days) if (seatCount = 16) return days * 800; else return days * 1500; import java.util.Scanner;public class TestRent public static void main(String args) String no,brand,mtype,type; int seatCount,days,rent; Car car; Bus bus; Scanner input = new Scanner(System.in); System.out.println(欢迎您来到汽车租赁公司!); System.out.print(请输入要租赁的天数:); days=input.nextInt(); System.out.print(请输入要租赁的汽车类型(1:轿车 2、客车):); mtype = input.next(); if(1.equals(mtype) System.out.print(请输入要租赁的汽车品牌(1、宝马 2、别克):); brand=input.next(); System.out.print(请输入轿车的型号 ); if(1.equals(brand) System.out.print((1、550i):); else System.out.print((2、商务舱GL8 3、林荫大道)); type=input.next(); no=京BK5543;/简单起见,直接指定汽车牌号 System.out.println(分配给您的汽车牌号是:+no); car =new Car(no,brand,type); rent=car.calRent(days); else System.out.print(请输入要租赁的客车品牌(1、金杯 2、金龙):); brand=input.next(); System.out.print(请输入客车的座位数:); seatCount=input.nextInt(); no=京AU8769;/简单起见,直接指定汽车牌号 System.out.println(分配给您的汽车牌号是:+no); bus=new Bus(no,brand,seatCount); rent=bus.calRent(days); System.out.println(n顾客您好!您需要支付的租赁费用是+rent+。);
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 考试试卷


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!