《JAVA语言程序设计》期末考试复习资料(6)

2019-03-11 11:20

《JAVA程序设计》期末考试试题 (七)

一、选择题

1. 请说出下列代码的执行结果 : ( B ) String s = \ String s1 = new String(s);

if (s = = s1) System.out.println(\ if (s.equals(s1)) System.out.println(\ A. the same equals C. the same

2. 下列有关 Java 中接口的说法哪个是正确的? ( B ) A. 接口中含有具体方法的实现代码

B. 若一个类要实现一个接口,则用到 “implements” 关键字 C. 若一个类要实现一个接口,则用到“ extends ”关键字 D. 接口不允许继承

3. 下列代码的执行结果是什么? ( B ) String s1 = \ s1.concat(\ System.out.println(s1); A. The string \ B. The string \ C. The string \ D. The string \

4. 如果有一个对象 myListener ( 其中 myListener 对象实现了 ActionListener 接口 ), 下列哪条语句使得 myListener 对象能够接受处理来自于 smallButton 按钮对象的动作事件 ? ( C ) A. smallButton.add(myListener); B. smallButton.addListener(myListener); C. smallButton.addActionListener(myListener); D. smallButton.addItem(myListener);

二.读程序题

B. equals D. 什么结果都不输出

1. 读下列代码,说出这段程序的功能。 import java.io.*; public class Test{

public static void main( String [] argv) { try {

BufferedReader is =

new BufferedReader( new InputStreamReader(System.in));

String inputLine;

While ((inputLine = is.readLine ())!= null) {

System.out.println(inputLine);

} is.close();

}catch (IOException e) {

System.out.println(\

} } }

答案:读取键盘输入,显示到屏幕上,直到键盘输入为空为止。

2、 读下列程序,写出正确的运行结果。 class test {

public static void main (String [] args ){

int x=9, y; if (x>=0)

if (x>0)

y=1; else y=0;

else y=-1;

System.out.println(y);

} } 答案:1

3、 读程序,写出正确的运行结果。

public class Father{

int a=100; public void miner(){

a--;

}

public static void main(String[] args){

Father x = new Father(); Son y = new Son(); System.out.println(y.a); System.out.println( y.getA()); y.miner();

System.out.println(y.a); System.out.println(y.getA());

} }

class Son extends Father{

int a = 0; public void plus(){ a++; }

public int getA() { return super.a; } } 答案: 0 100 0 99

三 . 简答题

3. 在 Java中,怎样创建一个线程? 答:

1、定义类来实现Runnable接口

class TestThread implements Runnable { public void run() { ?} }

2、继承Thread类来实现

class TestThread extends Thread { TestThread(String name) { super(name); start(); }

public void run() {?} }


《JAVA语言程序设计》期末考试复习资料(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:浅谈房地产企业全面预算管理中存在的问题及对策

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: