- 1、本文档共5页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
《JAVA语言程序设计》期末考试试题及答案7(应考必备题库)
一、选择题
1.请说出下列代码的执行结果:
Strings=abcd;
Strings1=newString(s);
if(s==s1)System.out.println(thesame);
if(s.equals(s1))System.out.println(equals);
A.?thesameequals B.?equals
C.?thesame D.?什么结果都不输出
A.?thesameequals B.?equals
C.?thesame D.?什么结果都不输出
2.下列有关Java中接口的说法哪个是正确的?
A.?接口中含有具体方法的实现代码
B.?若一个类要实现一个接口,则用到“implements”关键字
C.?若一个类要实现一个接口,则用到“extends”关键字
D.?接口不允许继承
3.下列代码的执行结果是什么?
Strings1=aaa;
s1.concat(bbb);
System.out.println(s1);
A.?Thestringaaa.
B.?Thestringaaabbb.
C.?Thestringbbbaaa.
D.?Thestringbbb.
4.如果有一个对象myListener(其中myListener对象实现了ActionListener接口),下列哪条语句使得myListener对象能够接受处理来自于smallButton按钮对象的动作事件?
A.?smallButton.add(myListener);
B.?smallButton.addListener(myListener);
C.?smallButton.addActionListener(myListener);
D.?smallButton.addItem(myListener);
二.读程序题
1.读下列代码,说出这段程序的功能。
importjava.io.*;
publicclassTest{
publicstaticvoidmain(String[]argv){
try{
BufferedReaderis=
newBufferedReader(newInputStreamReader(System.in));
StringinputLine;
While((inputLine=is.readLine())!=null){
System.out.println(inputLine);
}
is.close();
}catch(IOExceptione){
System.out.println(IOException:+e);
}
}
}
答案:读取键盘输入,显示到屏幕上,直到键盘输入为空为止。
2、读下列程序,写出正确的运行结果。
classtest{
publicstaticvoidmain(String[]args){
intx=9,y;
if(x=0)
if(x0)
y=1;
elsey=0;
elsey=-1;
System.out.println(y);
}
}
答案:1
3、读程序,写出正确的运行结果。
publicclassFather{
inta=100;
publicvoidminer(){
a--;
}
publicstaticvoidmain(String[]args){
Fatherx=newFather();
Sony=newSon();
System.out.println(y.a);
System.out.println(y.getA());
y.miner();
System.out.println(y.a);
System.out.println(y.getA());
}
}
classSonextendsFather{
inta=0;
publicvoidplus(){
a++;
}
publicintgetA(){
returnsuper.a;
}
}
答案:
0
100
0
99
三.简答题
1.?Java语言的特点。
答:
简单性:Java风格类似于C++,但它摒弃了C++中容易引起程序
文档评论(0)