文档介绍:《JAVA语言程序设计》期末考试试题及答案
一、选择题
1. 请说出下列代码的执行结果:
String s = "abcd";
String s1 = new String(s);
if (s = = s1) ("the same");
if ((s1)) ("equals");
A.  the same equals B.  equals
C.  the same D.  什么结果都不输出
2. 下列有关 Java 中接口的说法哪个是正确的?
A.  接口中含有具体方法的实现代码
B.  若一个类要实现一个接口,则用到“implements”关键字
C.  若一个类要实现一个接口,则用到“ extends ”关键字
D.  接口不允许继承
3. 下列代码的执行结果是什么?
String s1 = "aaa";
("bbb");
(s1);
A.  The string "aaa".
B.  The string "aaabbb".
C.  The string "bbbaaa".
D.  The string "bbb".
4. 如果有一个对象 myListener ( 其中 myListener 对象实现了 ActionListener 接口), 下列哪条语句使得 myListener 对象能够接受处理来自于 smallButton 按钮对象的动作事件?
A.  (myListener);
B.  (myListener);
C.  (myListener);
D.  (myListener);
1. 读下列代码,说出这段程序的功能。
import .*;
public class Test{
public static void main( String [] argv) {
try {
BufferedReader is =
new BufferedReader( new InputStreamReader());
String inputLine;
While ((inputLine = ())!= null) {
(inputLine);
}
();
}catch (IOException e) {
("IOException: " + e);
}
}
}
答案:读取键盘输入,显示到屏幕上,直到键盘输入为空为止。
2、读下列程序,写出正确的运行结果。
class test {
public static void main (String [] args ){
int x=9, y;
if (x>=0)