2017年计算机2级Java检测试题

来源:文书网 1.46W

Java 编程语言是个简单、面向对象、分布式、解释性、健壮、安全与系统无关、可移植、高性能、多线程和动态的语言。下面是小编收集的计算机2级Java检试题,希望大家认真阅读!

2017年计算机2级Java检测试题

  单选题

1). 顺序存储结构____。

A.仅适合于静态查找表的存储

B.仅适合于动态查找表的'存储

C.既适合静态又适合动态查找表的存储

D.既不适合静态又不适合动态查找表的存储

正确答案:C

2). 在编写Java application程序时,若需要使用到标准输入输出语句,必须在程序的开头写上____语句。

rt .*;

rt et;

rt .*;

rt hics;

正确答案:C

3). 关于以下程序段的执行结果,说法正确的是public class Borley extends Thread{public static void main(String argv[]){Borley b = new Borley(); t(); }public void run(){tln("Running");}}

A.编译通过并执行,但无输出

B.编译通过并执行,输出:Running

C.产生错误,没有Thread类对象

D.产生错误,没有通道到达Thread包

正确答案:B

4). 线性表若采用链表存储结构时,要求内存中可用存储单元的地址____。

A.必须是连续的

B.部分地址必须是连续的

C.一定是不连续的

D.连续不连续都可以

正确答案:D

5). 在Java中,能实现多重继承效果的方式是____。

A.内部类

B.适配器

C.接口

D.同步

正确答案:C

6). 在编写异常处理的Java程序中,每个catch语句块都应该与____语句块对应,使得用该语句块来启动Java的异常处理机制。

-else

ch

w

正确答案:C

  简单应用题(共24分)

本题的功能是通过按钮来选择窗口显示的风格。窗口

中有三个按钮:“Metal”、“Motif”和“Windows”,单击任何一

个按钮,就能将窗口的风格改变为按钮名称所对应的风格。

import .*;

import t.*;

import g.*;

class PlafPanel extends JPanel implements ActionLis-

tener

{public ()

{metaIButton=new JButton("Metal");

motifButtOn=new J Button("Motif");

windowsButton=new JButton("Windows");

add(metalButton);

add(motifButton);

add(windowsButton);

ctionListener(this);

ctionListener(this);

ctionListener(this);

}

Dublic void actionPerformed(ActionEvent evt)

{Object source=ource();

String plaf="":

if(source= =metalButton)

plaf="lLookAnd-

Feel";

else if(source= =motifButton)

plaf="-

fLookAndFeel";

else if(source= =windowsButton)

Dlaf="-

dowsLookAndFeel";

try

{ookAndFeel( );

teComponentTreeUI(this);

}

catch(Exception e){)

}

private JButton metalButton;

private JButton motifButton;

private JButton windowsButton;

}

class PlafFrame extends JFrame

{public PlafFrame()

{ setTitle("simple");

setSize(300,200);

addWindowListener(new WindowAdapter()

{public void windowClosing(WindowEvent e)

{(O);

}

});

Container contentPane=getContentPane();

(new PlafPanel());

}

}

public class java2

{public static void main(String[]args)

f JFrame frame=new PlafFrame();

();

}

热门标签