收藏 分销(赏)

Java程序设计C卷.doc

上传人:仙人****88 文档编号:12024716 上传时间:2025-08-29 格式:DOC 页数:6 大小:74.50KB 下载积分:10 金币
下载 相关 举报
Java程序设计C卷.doc_第1页
第1页 / 共6页
Java程序设计C卷.doc_第2页
第2页 / 共6页


点击查看更多>>
资源描述
<p>&nbsp; 院(系) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 专业 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;姓名 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;学号 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 班级 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 密封线内不要答题 ……………………………………密……………………………………封………………………………………线……………………………………… 《Java语言程序设计》 得分 评卷人 一.选择题:本大题共20小题;每小题1分,共20分。在每小题给出的四个选择中,只有一项是符合题目要求的,把所选择项前的字母填在题后的括号内。 1.一个Java源程序编译后生成的文件为Test.class,则运行该程序应该使用的命令为( &nbsp; )。 (A)javac Test &nbsp; &nbsp; &nbsp; &nbsp; (B)javac Test.class (C)java Test &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(D)java Test.class 2. class Value{ public int i = 15; } public class Test{ public static void main(String argv[]){ Test t = new Test(); t.first(); &nbsp; } public void first(){ &nbsp; &nbsp; int i = 5; Value v = new Value(); v.i = 25; second(v, i); &nbsp; System.out.println(v.i); } public void second(Value v, int i){ i = 0; v.i = 20; Value val = new Value(); v = val; System.out.println(v.i + &quot; &quot; + i); } } A.15 0 20 B.15 0 15 C.20 0 20 D.0 15 20 3. 类可以保护它的成员变量和成员函数不会被其他对象随意访问到,这一特性属于类的( &nbsp; )。 (A)封装性 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (B)继承性 (C)多态性 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (D)重载 4. 以下关于字符串类的说法正确的是( &nbsp; )。 &nbsp; &nbsp; (A)String类用于字符串变量,而StringBuffer类用于字符串常量 (B)String类用于字符串常量,而StringBuffer类用于字符串变量 (C)String类的对象只能用“new”关键字生成 (D)StringBuffer字符串的容量是指字符串中字符的个数 5. 以下( &nbsp; )声明是合法的。 (A) protected class Student; (B) public final static int w( ) (C) abstract double d; (D) abstract final double hyperbolicCosine( ) 6. 在子类的定义中有一个和父类同名的成员函数,这一现象称为函数的( &nbsp; )。 (A)继承 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(B)覆盖 (C)错误 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(D)重载 7. public class Static{ static{ int x = 5; &nbsp; } static int x,y; &nbsp; public static void main(String args[]){ x--; &nbsp; myMethod(); System.out.println(x + y + ++x); } public static void myMethod(){ y = x++ + ++x; } } A.编译错误 B.输出1 C.输出2 D.输出3 8. 在基于Swing的图形用户界面设计中,下面哪一个属于中间级容器( &nbsp; )。 (A)框架 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(B)面板 (C)小程序 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(D)对话框 9. 语句( &nbsp; )能够正确创建并初始化一个数组。 (A) int[5] ia = {15,10,3,9,11}; &nbsp; &nbsp;(B) float fa = new float [20]; (C) char[] ca = “Some String”; &nbsp; (D) Object oa = new float[20]; 10. 在Swing中,以下设置标签的步骤中,不需要的是( &nbsp; )。 (A)创建一个标签对象 (B)为标签设置动作监听器 (C)设置标签的文字、字体、属性等 (D)将标签放到面板上 11. 如果重写了Applet的paint方法,在( &nbsp; &nbsp;)中,AWT线程会自动调用paint 方法绘图。 (A) 当浏览器运行时。 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (B)当Applet 内容被覆盖后又重新显示时。 (C) 在执行repaint方法重新绘图时。 &nbsp; (D) 包括以上三种情况。 12. 下面哪种注释能支持javadoc命令( &nbsp; )。 (A)// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (B)/*......*/ (C)/**......*/ &nbsp; &nbsp; &nbsp; &nbsp;(D)都能支持 13. 编译和运行下面代码将会发生( &nbsp; )情况。 public class Test { public static void main(String [] args) { String foo = &quot;blue&quot;; String bar = foo; foo = &quot;green&quot;; System.out.println(bar);} } (A)运行时抛出异常。 (B) 运行时输出null。 (C) 运行时输出green。 (D) 运行时输出blue。 14. 对于Swing组件中的文本框对象myText,读取用户输入的操作是( &nbsp; )。 (A)myText.Text (B)myText.getText( ) (C)myText.Text( ) (D)myText.getText 15. 已知如下定义:String s = &quot;story&quot;;表达式( &nbsp; )不合法。 (A) s += &quot;books&quot;; &nbsp;(B) char c = s[1]; (C) int len=s.length(); &nbsp; &nbsp; &nbsp;(D) String t = s.toLowerCase(); 16. 若有URL aURL = new URL(&quot;:80/docs/books/&quot; + &quot;tutorial/index.html#DOWNLOADING&quot;);,则调用aURL.( &nbsp; )方法可得http。 (A) getProtocol() &nbsp;(B) getHost() &nbsp; (C) getPort() &nbsp; (D) getRef() 17. 下面哪个修饰符修饰的变量是所有同一个类生成的对象共享的( &nbsp; )。 (A)public &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (B)private (C)static &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (D)final 18. 下面哪个是对字符串String的正确定义。( &nbsp; ) (A)String s1=“\n\t null”; (B)String s2=‘null’ ; (C)String s3=(String)‘abc’ ; (D)String s4=(String)‘\uface’; 19. 给出一段程序,试判断哪个是正确的结果。( &nbsp; ) public class Test{ public static void main (String args[]){ &nbsp; &nbsp; &nbsp; try{ System.out.print(“Hello world ”); } &nbsp; &nbsp; &nbsp; finally{System.out.println(“Finally executing”); } } } (A)无法编译运行,因为没有指定异常 (B)无法编译运行,因为没有catch子句 (C)Hello world (D)Hello world Finally executing 20. class MyParent { int x, y; MyParent(int x, int y){ this.x = x; this.y = y; } public int addMe(int x, int y){ return this.x + x + y + this.y; } public int addMe(MyParent myPar){ return addMe(myPar.x, myPar.y); } } class MyChild extends MyParent{ int z; MyChild (int x, int y, int z){ super(x,y); this.z = z; } public int addMe(int x, int y, int z){ return this.x + x + this.y + y + this.z + z; } public int addMe(MyChild myChi){ return addMe(myChi.x, myChi.y, myChi.z); } public int addMe(int x, int y){ return this.x + x + this.y + y; } } public class MySomeOne{ public static void main(String args[]){ MyChild myChi = new MyChild(10, 20, 30); MyParent myPar = new MyParent(10, 20); int x = myChi.addMe(10, 20, 30); int y = myChi.addMe(myChi); int z = myPar.addMe(myPar); System.out.println(x + y + z); } } A.300 B.240 C.120 D.180 得分 评卷人 二.填空题:本大题共11小题,15个空;每个空2分,共30分。请在下划线上填写正确答案。 1.一个Java源程序保存时的文件扩展名是 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;。 2.类的成员有四级访问级,它们分别是 &nbsp; &nbsp; &nbsp; &nbsp; 、public、 &nbsp; &nbsp; &nbsp; &nbsp; 和package。。 3.Java中有两种字符串类,一个是String,另一个是 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 。假定一个字符串str已经正确定义,则要使用表达式表示字符串的长度,该表达式为 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 。 4.在一个异常处理语句中,可以多次出现的是 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;语句。 5.基于Swing的图形用户界面程序设计中,常用的顶层容器有三种,分别是框架、 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 和小程序。 6.Java小程序不能单独运行,必须将编译后的文件嵌入到网页中,将其嵌入时使用的标记是&lt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&gt;标记。 7.在多线程程序设计中,若要启动一个线程需要调用的函数是 &nbsp; &nbsp; &nbsp; &nbsp; 。 8.关键字______用于导入包中的类到程序中,供程序中使用。 9.要使一个JFrame能够正常显示,两个必须的方法是: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 和 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 。 10.在图形用户界面程序设计中,判断单选框的方法是 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ,获取文本框内容的方法是 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;。 11.要使用包中的类,必须用关键字 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;导入这些类所在的包。 得分 评卷人 三.判断题:本大题共10小题;每小题1分,共10分。若你判断出描述正确,请在小题后的括号内填“T”;若你判断出描述错误,请在小题后的括号内填“F”。使用其他符号得0分。 1.Java语言是一种面向对象程序设计语言。( &nbsp; &nbsp;) 2.在Java有布尔类型,该类型只能有两个值:1和0。( &nbsp; &nbsp;) 3.Java中一个类可以同时继承多个其他类,但只能实现一个接口。( &nbsp; &nbsp;) 4.在Java中字符串的长度和字符串中字符的个数是相等的。( &nbsp; &nbsp;) 5.程序中的异常是错误的一种,通过调试程序可以解决异常。( &nbsp; &nbsp;) 6.使用Java语言既可以读写二进制文件,又可以读写文本文件。( &nbsp; &nbsp;) 7.框架JFrame作为图形用户界面的顶级容器,原子组件是不能直接放置到框架的。( &nbsp; &nbsp;) 8.当最小化小程序时就会调用小程序的stop()方法,暂时释放所占资源。( &nbsp; &nbsp;) 9.调试Java程序也就是运行Java程序,使用java命令即可完成。( &nbsp; &nbsp;) 10.线程就是程序,只不过是代码较少。( &nbsp; &nbsp;) 得分 评卷人 四.简答题:本大题共3小题;每小题5分,共15分。请在每小题下面的空白处作答。 1.简述在类的继承关系中,子类可以继承父类的哪些成员,不能继承哪些成员。 2.抽象类和接口有什么不同? 3.在Java中产生一个线程的两种办法分别是什么?简单举例说明。 得分 评卷人 五.程序填空:本大题共3小题,5个空;每空3分,共15分。请在下划线上填写正确答案。 1.根据下面程序段写出输出结果。 int &nbsp;a = 1,b=2; String str = “hello”; System.out.println(str+a+b); System.out.println(a+b+str); 程序两次输出结果分别为 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.有以下类的定义 class &nbsp;FatherTest { public FatherTest( ){ //第①个输出 System.out.println(“hello”);; } public FatherTest(String s) { this( ); //第②个输出 System.out.println(“hello,”+s);; } } class Test extends FatherTest { public Test(String s) { super(s) ; //第③个输出 System.out.println(“how are you”+s); } public static void main(String[] args) { Test t = new Test(“Tom”) ; } } 运行程序后,输出结果为: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (注意:只用填写输出次序) 3.以下程序段是图形界面设计中在一个框架上放置两个单选框,其中两个选项为“男”和“女”,缺省情况下“男”选项被选中。请把程序段补充完整。 JFrame &nbsp;aFrame=new JFrame(“主框架”); JPanel &nbsp;aPanel=new JPanel( ); JRadioButton &nbsp;manRBtn= &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; JRadioButton &nbsp;womanRBtn=new JRadioButton(“女”); aFrame.getContentPane().add( &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ); ButtonGroup &nbsp;group=new &nbsp;ButtonGroup( ); group.add(); group.add(); aPanel.add(manRBtn); aPanel.add(womanRBtn); 得分 评卷人 六.程序设计:本大题共1小题;每小题10分,共10分。 1. 编写一个矩形类Rect,包含: (1)两个private属性:矩形的宽width;矩形的高height。 (2)两个构造方法:一个带有两个参数、一个不带参数的构造方法,其中不带 参数的构造方法将矩形初始化为宽和高都为10.0。 (3)两个方法:求矩形面积的方法area()和求矩形周长的方法perimeter()。 (4)获取长和宽的方法getWidth()和getHeight(); 《 Java语言程序设计 》试卷 &nbsp;第11页(共 8 页) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 《 &nbsp;Java语言程序设计 &nbsp;》试卷 &nbsp;第12页(共 8 页) &nbsp;</p>
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 考试专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服