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

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

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

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

2、。 11.对象引用中存储的内容是 。 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

3、语言中关键字_ _表示双精度类型。 15.保留字_ _用于导入包中的类到程序中,供程序中使用。 16.Java 语言中继承是用保留字 表示。 17.面向对象程序设计中,类是指 。 18.对象包含 和 。 19.若有类定义: class B extends A 则类 B 是类 A 的_ 。 20.Java 语言中, 通常把可能发生异常的方法调用语句放到 try 块中,并用紧跟其后的_ 块来 捕获和处理异常。 21.多态是指 。 22.声明常量时使用修饰符 。 23.Java 中异常抛出使用保留字 。 第 2 页共 11 页 24.一个类成员或者方法前面加上了 修饰符,那说明该数据成员和方法可以直

4、接通过类名 来访问和调用。 25.如果类成员前面没有访问权限修饰符,则该类成员具有 访问权限。 26.下面 构造方法是非法的 a): 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 程序的源

5、文件以 为扩展名,编译后的文件以 为扩展名。 二、简答题:二、简答题: 1.类和对象的概念和关系是什么? 2.请说明对象声明和对象生成之间的区别,并使用内存状态图举例说明这种区别。 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.检查型异常和非检查型异常有何区别?

6、9.请改造下面的构造方法,使第一个构造方法调用第二个构造方法。 public ClassOne(int alpha) this.alpha = alpha; this.beta = 0; public ClassOne(int alpha , int beta) this.alpha = alpha; this.beta = beta; 第 3 页共 11 页 10.Java 有哪几个访问权限修饰符,各起到什么作用? 11.请说明实例方法、类方法和构造器方法的特点和区别。 三、请写出下面的代码段的输出结果:三、请写出下面的代码段的输出结果: 1.class Q2main public stat

7、ic void main(string args) QuestionTwo q2; q2= new QuestionTwo(); q2.init(); q2.increment(); q2.increment(); system.out.println(q2.getCount(); class QuestionTwo private int count; public void int() count=1; public void increment() count=count+1; public int getCount() return count; 2.int gradeLevel; s

8、witch (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); case 4: System.out.print(Go to 404); break; default: System.out.print(default); 如果变量 gradeLevel 在 switch 语句之前为以下数值,上述程序代码段执行后,将分别输出什么? a)2 b)3 c)4 d)5 3.int x;

9、 第 4 页共 11 页 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(); 输出结果为: 4.class MyException1 extends Exception public MyException1() public MyException1(String msg) super(msg); public class ExceptionTes

10、t public static void f() throws MyException1 System.out.println(The 1st line of f(); throw new MyException1(Exception1:Originated in f(); public static void main(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 lin

11、e 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(); 输出结果为: 5.import java.io.*; class Base Base() System.out.println(Base(); void m1() System.out.println(Base.m1(); class Derived extends Ba

12、se Derived() this(default); System.out.println(Derived(); Derived(String ss) 第 5 页共 11 页 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.prin

13、tln(Shape.draw(); class Circle extends Shape void draw() System.out.println(Circle.draw(); class Square extends Shape void draw() System.out.println(Square.draw(); public class Shapes public static void main(String args) Shape s = new Shape3; s0=new Shape(); s1=new Circle(); s2=new Square() for(int

14、i = 0; i 3; i+) si.draw(); 输出结果为: 7.try number = Integer. parseInt(“-30”); i f (number 0) throw new Exception(“No negative”); catch(NumberFormatException e) System.out.println(“Can not covert to int”); 第 6 页共 11 页 catch (Exception e ) System.out.println(“Error:”+e.getMessage(); finally System.out.println(“DONE”); 输出结果为: 8.class Value int i=10; class Tester public static void test(int x) x=20; public static void test(Value v) v.i =20; public s

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 资格认证/考试 > 其它考试类文档

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