面向对象程序设计复习题及参考答案

上传人:夏** 文档编号:488095160 上传时间:2023-08-26 格式:DOC 页数:13 大小:69.50KB
返回 下载 相关 举报
面向对象程序设计复习题及参考答案_第1页
第1页 / 共13页
面向对象程序设计复习题及参考答案_第2页
第2页 / 共13页
面向对象程序设计复习题及参考答案_第3页
第3页 / 共13页
面向对象程序设计复习题及参考答案_第4页
第4页 / 共13页
面向对象程序设计复习题及参考答案_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《面向对象程序设计复习题及参考答案》由会员分享,可在线阅读,更多相关《面向对象程序设计复习题及参考答案(13页珍藏版)》请在金锄头文库上搜索。

1、真诚为您提供优质参考资料,若有不当之处,请指正。网络教育课程考试复习题及参考答案面向对象程序设计一、填空题:1.创建类的对象时,使用运算符_给对象分配内存空间。2.Java通过 来区分重载函数。3.在子类中使用保留字_ _可调用被子类覆盖的父类中的方法。4.使用保留字 可以从一个构造方法中调用同一个类的另一个构造方法。5.抽象类用修饰符 定义。6.类的数据成员的访问权限修饰符一般为 7.访问权限修饰符按照访问权限的大小从大到小分别为 、 、 、 。8.定义类的构造方法不能有 ,其名称与 名相同。9.抽象方法是的特征是 。10.Java中的所有异常都是从 继承来的。11.对象引用中存储的内容是

2、。12.下列程序段执行后,String str1 = new String(Java);String str2 = new String(Java);if (str1.equals(str2) System.out.println(They are equal); else System.out.println(They are not equal);输出结果为: 。13.下面循环执行后的sun值为 int count =0, sum = 0;while ( count 10 ) sum += count; count +;14.Java语言中关键字_ _表示双精度类型。15.保留字_ _用于

3、导入包中的类到程序中,供程序中使用。16.Java语言中继承是用保留字 表示。17.面向对象程序设计中,类是指 。18.对象包含 和 。19.若有类定义:class B extends A 则类B是类A的_ 。20.Java语言中, 通常把可能发生异常的方法调用语句放到try块中,并用紧跟其后的_ 块来捕获和处理异常。21.多态是指 。22.声明常量时使用修饰符 。23.Java中异常抛出使用保留字 。24.一个类成员或者方法前面加上了 修饰符,那说明该数据成员和方法可以直接通过类名来访问和调用。25.如果类成员前面没有访问权限修饰符,则该类成员具有 访问权限。26.下面 构造方法是非法的a)

4、:public int ClassA(int one) b):public ClassB(int one,int two) c):ClassC() 27.程序填空:public void getData() String str = JoptionPane.showInputDialog(null,”Input:”); if (str.equals(“”) throw new IOException(); )28.对象称为类的 。29.Java程序的源文件以 为扩展名,编译后的文件以 为扩展名。二、简答题:1.类和对象的概念和关系是什么?2.请说明对象声明和对象生成之间的区别,并使用内存状态图

5、举例说明这种区别。3.this和super两个保留字的意义和作用是?4.构造器方法有什么特点和作用?5.保留字throw和throws有什么区别?6.将下面的while 循环改写为for循环int count =1, sum = 0;while ( count = 30 ) sum += count; count +=3;7.Java语言编译和执行的过程是?8.检查型异常和非检查型异常有何区别?9.请改造下面的构造方法,使第一个构造方法调用第二个构造方法。public ClassOne(int alpha) this.alpha = alpha; this.beta = 0;public Cl

6、assOne(int alpha , int beta) this.alpha = alpha; this.beta = beta;10.Java有哪几个访问权限修饰符,各起到什么作用?11.请说明实例方法、类方法和构造器方法的特点和区别。三、请写出下面的代码段的输出结果:1.class Q2main public static void main(string args) QuestionTwo q2; q2= new QuestionTwo(); q2.init(); q2.increment(); q2.increment(); system.out.println(q2.getCoun

7、t(); class QuestionTwo private int count; public void int() count=1; public void increment() count=count+1; public int getCount() return count; 2.int gradeLevel; switch (gradeLevel) case 1: System.out.print(Go to the 101);case 2: System.out.print(Go to 202); break;case 3: System.out.print(Go to 303)

8、;case 4: System.out.print(Go to 404); break;default: System.out.print(default);如果变量gradeLevel 在switch语句之前为以下数值,上述程序代码段执行后,将分别输出什么?a) 2b) 3c) 4d) 53.int x;for (int width = 1; width =20, width+) for (int length = 5, length =25, length+=5) x = width * length; System.out.print ( + x); System.out.println

9、();输出结果为: 4.class MyException1 extends Exception public MyException1() public MyException1(String msg) super(msg); public class ExceptionTest public static void f() throws MyException1 System.out.println(The 1st line of f(); throw new MyException1(Exception1:Originated in f(); public static void mai

10、n(String args) System.out.println(The 1st line of main(); try System.out.println(The 2nd line of main(); f(); System.out.println(The 3rd line of main(); catch(MyException1 e) System.out.println(e.getMessage();finally System.out.println(The 4th line of main(); System.out.println(The 5th line of main(

11、); 输出结果为:5.import java.io.*;class Base Base() System.out.println(Base(); void m1() System.out.println(Base.m1(); class Derived extends Base Derived() this(default); System.out.println(Derived(); Derived(String ss) System.out.println(ss); void m1() System.out.println(Derived.m1(); public class Application1 public static void main(String args) Base b; b=new Derived(); b.m1(); 输出结果为:6.class Shape void draw() System.out.println(Shape.draw();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号