77范文网 - 专业文章范例文档资料分享平台

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

来源:网络收集 时间:2019-03-11 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

《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() {?} }

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库《JAVA语言程序设计》期末考试复习资料(6)在线全文阅读。

《JAVA语言程序设计》期末考试复习资料(6).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/516278.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: