栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

《面向对象程序设计(java)》复习题(七)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

《面向对象程序设计(java)》复习题(七)

一、选择题

1. 请说出下列代码的执行结果 :

String s = "abcd";

String s1 = new String(s);

if (s = = s1) System.out.println("the same");

if (s.equals(s1)) System.out.println("equals");

A.  the same    equals                      B.  equals //相等,

C.  the same                                    D.  什么结果都不输出

2. 下列有关 Java 中接口的说法哪个是正确的?

A.  接口中含有具体方法的实现代码

B.  若一个类要实现一个接口,则用到 “implements” 关键字   

C.  若一个类要实现一个接口,则用到“ extends ”关键字

D.  接口不允许继承

3. 下列代码的执行结果是什么?

String s1 = "aaa";

s1.concat("bbb");

System.out.println(s1);

A.  The string "aaa".

B.  The string "aaabbb".

C.  The string "bbbaaa".

D.  The string "bbb".

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

A.  smallButton.add(myListener);

B.  smallButton.addListener(myListener);

C.  smallButton.addActionListener(myListener);

D.  smallButton.addItem(myListener);

二.读程序题

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("IOException: " + e);

}

}

}

答案:读取键盘的输入,并显示,直到输出空(null)为止

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

 三 . 简答题

1.  Java语言的特点。

答: 面向对象的,跨平台性,可移植性好,容错性,分布式,简单性

2.  请描述 AWT事件模型。

答: 抽象

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

答:

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/462502.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号