《Java面向对象程序设计》科目考试卷及答案(2)

2020-04-14 23:10

}

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(\ }

}

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(\ }

}

class SubClass extends SuperClass{

int c;

SubClass(int aa,int bb,int cc){

super(aa,bb); c=cc;

} }

class SubSubClass extends SubClass {

int a;

第6页 共10页

}

case 2:a=a+2;

SubSubClass(int aa,int bb,int cc) {

super(aa,bb,cc); a=aa+bb+cc;

}

void show(){

System.out.println(\ }

}

5.下列程序段的运行结果为______________。 public class Test{

public static void foo(int i){ try{

if(i==1){

throw new Exception(); }

System.out.print(\ }catch(Exception e){

System.out.print(\ }finally{

System.out.print(\ }

System.out.print(\ }

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 test{

public static void main(String args[]){

//定义名为r1的对象同时初始化坐标为0,0,长度为10,宽度为20

___________【3】____________; } } 2.(7分)将一组乱序的字符进行升序和降序排列,并分别输出。输出格式如图1所示。

第7页 共10页

图1

3.(14分)汽车租赁公司出租多种车辆,车型和租金情况如下表所示。编写程序实现租赁价格的计算。

车型 日租费 (元/天) 别克商务舱GL8 600 轿车 宝马550i 500 别克林荫大道 300 客车(金杯、金龙) <=16座 800 >16座 1500 具体要求:车辆分为轿车和客车两大类,它们都继承自抽象类MotoVehicle,并实现其抽象方法calRent()。请根据下面给出的类图分别创建三个类,并在测试类TestRent中实现车辆的租赁。租赁过程如图2所示。

Car MotoVehicle -type:String

-no:String -brand:String + MotoVehicle () +MotoVehicle (no,brand) +getNo():String +getBrand():String +calRent():int +Car(no,brand,type) +getType():String + calRent():int Bus -seatCount:int +Bus(no,brand,seatCount) +getSeatCount ():String +calRent():int 第8页 共10页

图2

_______ ______________名_姓__ _ _ 线 _ ___________订____号_考_ _ _ 装 _ _______________级_班_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

安徽财贸职业学院2011—2012学年第二学期

__《Java面向对象程序设计》期末试卷答题卡(B卷)

__适用班级:软件1101

__ _题号 一 二 三 四 总分 __得分 _

__得分 评卷人 一、单选题(每小题1分,共30分)

__ _

_ __1 2 3 4 5 6 7 8 9 10 _ __11 12 13 14 15 16 17 18 19 20 _ __21 22 23 24 25 26 27 28 29 30 _ __ _得分 评卷人 二、填空题(每空2分,共20分) __ __

__1.__________________ ____________________ __2.__________________ ____________________ _3.__________________ ____________________ __4.__________________ ____________________ __5.__________________ 6.__________________ __ __得分 评卷人 三、阅读理解题(每题4分,共20分) __

__

_1.__________________ 2.__________________ __

_3.__________________ 4.__________________ __

_5.__________________

_第9页 共10页

___

四、编程题(共30分)

1.(每空3分,共9分)

【1】_______________________ 【2】_______________________

【3】_____________________________________ 2.(7分)

得分 评卷人 3.(14分)

第10页 共10页


《Java面向对象程序设计》科目考试卷及答案(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:我国选举制度的形成及其基本内容

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: