java自考习题全套

上传人:枫** 文档编号:478412364 上传时间:2023-05-18 格式:DOCX 页数:63 大小:175.26KB
返回 下载 相关 举报
java自考习题全套_第1页
第1页 / 共63页
java自考习题全套_第2页
第2页 / 共63页
java自考习题全套_第3页
第3页 / 共63页
java自考习题全套_第4页
第4页 / 共63页
java自考习题全套_第5页
第5页 / 共63页
点击查看更多>>
资源描述

《java自考习题全套》由会员分享,可在线阅读,更多相关《java自考习题全套(63页珍藏版)》请在金锄头文库上搜索。

1、文档来源为 :从网络收集整理.word 版本可编辑.欢迎下载支持Java 语言基础一、单选(每题 1 分)I.Java语言中,只限子类或者同一包中的类的方法能访问的访问权限是()A.publicB.privateC.protectedD.2 . Java语言中,在类定义时用 final关键字修饰,是指这个类()A.不能被继承B.在子类的方法中不能被调用C.能被别的程序自由调用D.不能被子类的方法覆盖3 .参照以下Java代码,以下四个叙述中最确切的是()class Aint x; static int y;void fac(String s)System. out. println( 字符串

2、: +s);A . x、y和s都是成员变量B. x是实例变量、y是类变量、s是局部变量C. x和y是实例变量、s是参数D . x、y和s都是实例变量4. 以下关于接口的叙述中,正确的是()A. 所有的接口都是公共接口,可被所有的类和接口使用B. 一个类通过使用关键字interface 声明自己使用一个或多个接口C. 接口中所有的变量都默认为 public abstract 属性D. 接口体中不提供方法的实现5在以下供选择的概念中,不属于 面向对象语言概念的是()A 消息B 模块C 继承D 多态性6.设类 U 声明,及对象u 和 v 的定义如下:class Uint x, int y;U(int

3、 a, int b)x= a; y = b;void copy(U a) x = a.x; y = a.y;U u = new U(1, 2), v = new U(2, 3);在以下供选择的代码中,可能引起系统回收内存的是()#;u.y=v.x;B.u=v;二、填空(每题2 分)1 .程序包声明的格式是。2 .当联编推迟至运行时间实现时,该联编过程称为 。3 import 语句的格式是 。4 在面向对象语言中,对象之间的交互通过实现。5. 类是对一组相同对象的描述,类概括了同类对象的共有性质: 。6. 在定义成员变量时,用关键字 修饰的是类变量。7. 如果类A某个成员变量的类型是类B,则类A

4、和类B之间是 关系。8. 在类声明之前用 修饰,声明类是不能被再继承的类,即它不能再有子类。三、简答题( 每小题 3 分)1.请写出 Applet 类中 init() 方法的功能。2以下代码定义了一个类,请指出其中三条不合法的代码行(行号参见注释)。class Test22/1float u ; static float v ;/2static void setUV(boolean f)/3u=fac1(f) ;/4v=fac2(!f) ; /5/6/7static float facl(boolean f)return f?u:v; float fac2(boolean f)return f

5、?v:u;/83 .如果类Student是类Person的子类,类 Undergraduate是类Student的子类,请指出以 下代码行中哪些是不合法的。Person p1=new Student();Person p2=new Undergraduate();Student s1=new Person();Student s2=new Undergraduate();Undergraduate ug1=new Person();Undergraduate ug2=new Student();Object ob=new Student();4 . 请写出在面向对象系统中,类和对象的关系。5请

6、写出接口定义的一般形式。6.请写出在类的方法的定义之前,加上修饰字public、 private 的区别。五、程序分析题(本大题共5小题,每小题 4分,共 20 分)1.阅读下列程序,请写出该程序的输出结果。public class A int m = 5; static int n = 3;public static void main(String args) A obj 1 = new A(); A obj2 = new A();objl.m *= 2; objl.n *= 4; obj2.m += 1; obj2.n += 6;obj 1.m= + obj 1.m);obj 1.n=

7、+ obj 1.n);obj2.m= + obj2.m);obj2.n= + obj2.n);2阅读下列程序,请写出该程序的输出结果。class Tree private String name;public boolean flower;public int birthYear;Tree(String n, boolean f, int y) name = n; flower = f; birthYear = y; public void setName(String n)name = n;public String getName()return name; public void pri

8、ntTree(String str); Name:+name);Birth Year:+birthYear);Flower:+flower);class PineTree extends Tree public boolean coniferous = true;PineTree(String n, boolean f, int y, boolean c)super(n, f, y);coniferous = c; public void printTree(String str)super, printTree(str);Coniferous: + coniferous);class Tes

9、t32 public static void main(String args)Tree fOb = new Tree(May Flower, true, 1980);PineTree sOb = new PineTree(Pine, false, 2000, true);fOb.printTree( fOb:); sOb.printTree(sOb:);3 .阅读下列程序,请写出该程序的输出结果。import java.applet.*;import java.awt.*;class Pointint x,y;Point(int xx,int yy) x=xx;y=yy;Point(Poin

10、t p)x=p.x;y=p.y;void m(int dx,int dy)x+=dx;y+=dy;class Circle extends Pointint r;Circle(Point p, int rr) super(p); r=rr; float c() return 3.14f*2.0f*r;float a() return 3.14f*r*r;public class sample extends AppletCircle yuan; Point d;public void init() d=new Point(2,5);yuan=new Circle(d,10);public vo

11、id paint(Graphics g)g.drawString( yuan Circle +(int)(yuan.c()*100.0)/100.0,5,20);g.drawString( yuan Area +(int)(yuan.a()*100.0)/100.0,5,40);4 . 阅读下列程序,请写出该程序的输出结果。class Bint b ;B(int x)b=x ; b=+b) ; class A extends Bint a ;A(int x , int y)super(x) ; a=y ; b=+b+ , a=+a) ;public class a32public static

12、 void main(Stringargs)A obj=new A(1, 2) ;5阅读下列程序,请写出该程序的输出结果。class Parentprivate void method 1 () method 1() ); public void method 2 () method 2() ); method 1(); class Child extends Parent public void method l () method 1 () ); public static void main(String args) Parent p = new Child() ; p.method2(

13、) ; 6 .阅读下列程序,请写出该程序的输出结果。class A int x, y;A(int a, int b) x= a;y= b;public class sample public static void main(String args) A pl, p2;p2 = new A(12, 15);p1 = p2; p2.x+;p1.x= + p1 .x);一、单项选择题 ( 每小题 1 分)1 .在 Java 的类库中,包含实现输入/输出操作的包是()2 . Java语言可以用javax.swing包中白类JFileChooser来实现打开和保存文件对话框。用户通过文件对话框不可能获

14、得的信息是()A 文件名称B 文件路径C.文件内容D.文件对象3在以下供选择的方法中,不能 用于文件随机访问的方法是()A readChar()B readLong()C readInteger()D writeChars()4.程序如果要按行输入输出文件的字符流,最合理的方法是采用()A.BufferedReader 类和 BufferedWriter 类B.InputStream 类和 OutputStream 类C.FileReader 类和 FileWriter 类D.File_Reader 类和 File_Writer 类5为 16 位 Unicode 字符流提供读和写操作支持的类分别是( )A FileInputStream 类和 FileOutputStream 类B InputStream 类和 OutputStream 类C FileReader 类和 FileWriter 类D File_Reader 类和 File_Writer 类6. 当用户关闭文件

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

当前位置:首页 > 商业/管理/HR > 营销创新

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