华中科技大学本科《Java语言程序设计》试题闭卷文档格式.docx
- 文档编号:5189943
- 上传时间:2023-05-04
- 格式:DOCX
- 页数:13
- 大小:18.06KB
华中科技大学本科《Java语言程序设计》试题闭卷文档格式.docx
《华中科技大学本科《Java语言程序设计》试题闭卷文档格式.docx》由会员分享,可在线阅读,更多相关《华中科技大学本科《Java语言程序设计》试题闭卷文档格式.docx(13页珍藏版)》请在冰点文库上搜索。
3.类MyClass被声明为public类型,其成员字符串变量s只能被自己或同一个包中的其他类访问,满足条件的声明语句为:
矚慫润厲钐瘗睞枥庑赖。
A.privateStrings;
B.publicStrings;
C.protectedStrings;
D.packageStrings;
4.给定下列代码:
classA{
A(inti){
System.out.println("
ClassAConstructor"
+i);
}
publicclassBextendsA{
B(inti){
ClassBConstructor"
publicstaticvoidmain(Stringargs[]){
Bb=newB(100);
上述代码的编译运行结果是:
A.ClassBConstructor100
B.ClassAConstructor100
ClassBConstructor100
C.该程序会产生编译错误
D.程序编译通过,但运行时会产生异常并中止
5.关于Java语言中方法的参数传递,正确的描述是:
A.方法的参数均是按值传递
B.方法的参数均是按引用传递
C.方法的参数如果是基本类型,则按值传递;
否则按引用传递
D.可通过关键字来指定方法的参数是按值传递还是按引用传递
6.将int型变量i的值转换为String类型并赋值给字符串变量s(例如i=10,则s="
10"
),正确的写法是:
()聞創沟燴鐺險爱氇谴净。
A.s=i.toString();
B.s=Integer(i).toString();
C.s=Integer.valueOf(i);
D.s=String.valueOf(i);
7.如果希望某类中的公有成员变量可在其他类中通过"
类名.变量名"
进行引用,定义变量时应采用的修饰关键字是:
()残骛楼諍锩瀨濟溆塹籟。
A.static
B.native
C.final
D.finally
8.关于异常处理,下面说法不正确的是:
A.从RuntimeException直接或间接继承的异常可以不必捕获
B.如果某方法用throw语句抛出了异常,该方法声明时不一定必须指明throws子句
C.如果将父类异常的catch语句写在子类异常之前,那么程序运行时只会执行父类异常的语句
D.InterruptedException属于须检查的异常
9.如果需要将某个对象通过网络发送到远程系统,应采用那种合适的I/O类?
A.PipedReader/PipedWriter
B.PipedInputStream/PipedOutputStream
C.ObjectInputStream/ObjectOutputStream
D.DataInputStream/DataOutputStream
10.给定下列代码:
publicclassThreadTestextendsThread{
publicvoidrun(){
System.out.println("
Inrun"
);
yield();
Leavingrun"
}
publicstaticvoidmain(Stringargs[]){
(newThreadTest()).start();
上述程序编译运行的结果是:
A.Inrun
B.Leavingrun
C.Inrun
Leavingrun
D.程序正常运行,但什么都不显示
11、System类存在于下列哪一个包中?
A.java.lang
B.java.io
C.java.util
D.未定义包
12、关于System.out.println();
语句,说法正确的是:
A.out是System类的一个静态属性
B.out是System类的一个静态方法
C.println是System类的一个静态方法
D.println是System类的一个非静态方法
13、定义一个不允许被其它类所继承的类,可使用的类修饰符是:
B.final
C.protected
D.abstract
14、类A继承了类B,并实现了接口C,以下类的声明语句正确的是:
A.classAextendsBimplementsC
B.classAextendsCimplementsB
C.classBextendsAimplementsC
D.classBextendsCimplementsA
15、定义一个无返回值的抽象方法,以下语句正确的是:
A.abstractvoidtest(){}
B.abstractvoidtest();
C.voidabstracttest(){}
D.voidabstracttest();
16、类C的定义如下:
classCextendsBimplementsA{
…
下列表达式中,不正确的是:
A.Cc=newC();
B.Bb=newC();
C.Aa=newC();
D.Cc=newB();
17、希望按"
东南西北中"
的方位安排组件的摆放,容器应该采用那种布局类?
A.FlowLayoutB.BorderLayoutC.CardLayoutD.GridLayout酽锕极額閉镇桧猪訣锥。
18、下列不是Java引用类型的是:
A.int[]
B.Object
C.Runnable
D.char
19.给定下列代码:
classTest{
publicstaticvoidmain(String[]args){
Floats=newFloat(0.9F);
Floatt=newFloat(0.9F);
Doubleu=newDouble(0.9);
System.out.println(s==t);
System.out.println(s.equals(t));
System.out.println(t.equals(u));
上述程序的运行结果是:
A.true
true
true
B.false
C.false
true
false
D.false
20、给定下列代码:
classBase{
intx=2;
intmethod(){
returnx;
classSubclassextendsBase{
intx=3;
intmethod(){
Baseb=newSubclass();
System.out.println(b.x);
System.out.println(b.method());
上述代码的运行结果是:
A.23
B.22
C.33
D.32
E.以上都不对,因为Baseb=newSubclass()是非法语句
二、根据程序回答问题(共65分)
1、写出下列程序的运行结果(共20分)
(1)程序:
(6分)
classC{
C(){
System.out.print("
C"
classA{
Cc=newC();
A(){
this("
A"
A(Strings){
System.out.print(s);
classBextendsA{
B(){
super("
B"
publicstaticvoidmain(String[]args){
newB();
运行结果:
(2)程序:
(8分)
PublicclassNote{
publicstaticvoidswap(Stringname[]){
Stringtemp;
temp=name[0];
name[0]=name[1];
name[1]=temp;
}
publicstaticvoidswap(Stringname0,Stringname1){
temp=name0;
name0=name1;
name1=temp;
publicstaticvoidmain(Stringargs[]){
Stringname[]={"
Killer"
"
Miller"
};
Stringname0="
Stringname1="
swap(name0,name1);
System.out.println(name0+"
"
+name1);
swap(name);
System.out.println(name[0]+"
+name[1]);
(3)程序:
classUnchecked{
staticvoidmethod(){
try{
wrench();
a"
}catch(ArithmeticExceptione){
b"
}finally{
c"
d"
staticvoidwrench(){
thrownewNullPointerException();
publicstaticvoidmain(String[]args){
method();
}catch(Exceptione){
e"
f"
2、根据程序回答问题(共10分)
publicclassJLab0603{
publicstaticvoidchange(Strings){
s=s+"
changed?
"
}
publicstaticvoidchange(StringBuffersb){
sb.append("
publicstaticvoidmain(String[]args){
Strings="
test"
StringBuffersb=newStringBuffer("
System.out.println("
s="
+s+"
sb="
+sb);
change(s);
change(sb);
+s+"
}
(1)该程序的运行结果是:
(4分)
(2)用简洁明了的语言说明为什么会产生这样的结果?
3、根据程序运行结果填空(共15分)
注意:
一个空格处只能填写一条语句
classGate{
publicvoidwaitAtGate(){
try{
}catch(InterruptedExceptione){}
publicvoidnotifyAllAtGate(){
classTangledThread{
Gategate;
publicTangledThread(Stringstr,Gateg){
publicvoid{
try{sleep((int)(Math.random()*100));
catch(InterruptedExceptione){}
..."
+getName()+"
classLooseThread{
publicLooseThread(Stringstr,Gateg){
publicvoid{
publicclassThreadProblem{
publicstaticvoidmain(String[]args){
newTangledThread("
Study"
g).start();
Party"
newLooseThread("
Sleep"
该程序所有可能的运行结果为:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java语言程序设计 华中科技大学 本科 Java 语言程序设计 试题 闭卷
![提示](https://static.bingdoc.com/images/bang_tan.gif)
文档标签
- JAVA程序设计电子科技大学JAVA程序设计
- 华中科技大学标准语言程序
- 金陵科技学院语言程序设计
- 整理中山大学java程序设计
- 程序设计语言基本概念试题
- 本科试题程序设计0805
- JAVA程序设计教学大纲本科
- 华中科技大学中国语文水平
- 华中科技大学语言课程设计实验
- 华中科技大学汇编语言程序设计试卷
- 电大本科语言程序设计试题
- 华中科技大学卫生统计学试题
- 中山大学Java程序设计复习题
- Java程序设计模式中介
- Java语言简单文本
- Java语言程序设计华中科技大学本科Java
- 中南大学语言程序设计历年试题
- 桂林电子科技大学语言程序设计习题
- C语言电子科技大学20语言
- 电大本科审计学自测
- 语言程序设计电子教案
- VB程序设计电子科18VB
- 精编大学JAVA程序语言
- JAVA程序设计信息技术JAVA程序设计