电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

《面向对象程序设计——java》期末考试试题2008A卷

《面向对象程序设计——java》期末考试试题2008A卷_第1页
1/6
《面向对象程序设计——java》期末考试试题2008A卷_第2页
2/6
《面向对象程序设计——java》期末考试试题2008A卷_第3页
3/6
第 1 页 共 6 页 武 汉 大 学 计 算 机 学 院 2008— 2009 学年 度 第一 学期 期 末 考 试 《 JAVA 程 序 设 计》 试 卷 A 专 业 : ___________ 学号: ____________ 姓 名 : _________ 总分:_________ 一、单项选择题(1 0 小题 2 0 分) 1、编译和运行下列代码后结果是:( ) public class Test { static int total = 10; public static void main (String args [ ] ) { new Test(); } public Test () { System.out.println("In test"); System.out.println(this); int temp = this.total; if (temp > 5) System.out.println(temp); } } A. 编译器报第2 行有错 B. 编译器报第9 行有错 C. 在标准输出上打印的内容中有数字 10 D. 通过编译,但是产生运行时错误 2、下列类分别在不同的文件中定义:( ) class Vehicle { public void drive() { System.out.println("Vehicle: drive"); } } class Car extends Vehicle { public void drive() { System.out.println("Car: drive"); } } public class Test { public static void main (String args []) { Vehicle v; Car c; v = new Vehicle(); c = new Car(); v.drive(); c.drive(); v = c; v.drive(); } } 编译和执行类 Test 后,结果是:( )。 第 2 页 共 6 页 A. 在语句v= c;处产生编译时错误 B. 在语句v= c;处产生运行时错误 C. 输出: Vehicle: drive D. 输出: Vehicle: drive Car: drive Car: drive Car: drive Vehicle: drive 3、下列代码中的 public void add(int a)方法在add(5)形式调用下产生什么输出?( ) public class Test { public void add(int a) { loop: for (int i = 1; i < 3; i++) { for (int j = 1; j < 3; j++) { if (a == 5) break loop; System.out.println(i * j); } } } } A. 运行时错误 B. 抛出ArrayIndexOutOfBoundsException 异常 C. 输出:1, 2, 2, 4 D. 没有输出 4、在JAVA 中,类 Animal 中的方法 printA( )定义如下: public void printA( ){ int a=10; int result=10%3; System.out.println(result); } 在类 Dog 中方法 printA( )定义如下: public void pri...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

《面向对象程序设计——java》期末考试试题2008A卷

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部