2013年9月全国计算机等级《二级JAVA》考前冲刺试卷七

0
收藏   分享
  • 卷面总分:100分
  • 试卷类型:模拟考试
  • 测试费用:免费
  • 答案解析:是
  • 练习次数:26次
  • 作答时间:120分钟
试卷简介

2013年9月全国计算机等级《二级JAVA》考前冲刺试卷七:本试卷总分100分;共有4类型题目

  • 选择题
  • 基本操作题
  • 简单应用题
  • 综合应用题
试卷预览
1

本题中使用了选项卡,窗口中有一个选项卡,总共有“系统”、“声卡”、“显卡”、“网卡”和“帮助”5项选项面。单击各个选项的文字标签后,所选中的选项将为当前选项。“系统”选项上有3个复选按钮,分别控制“声卡”、“显卡”和“网卡”三个选项,选中某个按钮后,它所指示的选项就可用,否则不可用。

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.event.*;

public class java3 extends JFrame{

JTabbedPane config=new JTabbedPane:

public java3{

super("java3");

setSize(500,300);

setDefaultCloseoperation(EXIT_ON_CLOSE);

JPanel configPane=new JPanel;

configPane.setLayout(new BoxLayout(config-

Pane,BoxLayout.Y_AXIS));

JTextArea question=new JTextArea("下面的哪

个选项\n"+"你想设置?");

question.setEditable(false);

question.setMaximumSize(new Dimension(300,

50));

question.setAlignmentX(0.Of);

question.setBackground(configPane.getBack-

ground);

JCheckBox audioCB=new JCheckBox ("声卡",

true);

JCheckBox nicCB=new JCheckBox("网卡",

true);

JCheckBox tvCB=new JCheckBox("显示卡",

false);

configPane.add(Box.createVerticalGlue);

configPane.add(question);

configPane.add(audioCB);

configPane.add(nicCB);

configPane.add(tvCB);

configPane.add(Box.ereateVerticalGlue);

JLabel audioPane=new JLabel("声卡页面");

JLabel niePane=new JLabel("网卡页面");

JLabel tvPane=new JLabel("显示卡页面");

JLabel helpPane=new JLabel("帮助信息");

audioCB.addItemListener(new TabManager(au-

dioPane));

nicCB.addItemListener(new TabManager

(nicPane));

tvCB.addItemListener(new TabManager

(tvPane)):

config.addTab("系统",null,configPane,"

Choose Installed Options”);

config.addTab("声卡",null,audioPane,"Audio

system configuration”);

config.addTab("网卡",null,nicPane;"Netwot-

king configuration");

config.addTab("显示卡",null,tvPane,"Video

system configuration");

config.addTab("帮助",null,helpPane,"How

Do I…");

getContentPane.add(config,BorderLayout.

CENTER);

}

class TabManger implements ActionListener{

Component tab;

public TabManager(Component tabToManage){

tab=tabToManage;

}

public void ItemStateChanged(ItemEvent ie){

int index=config.indexOfComponent(tab);

if(index!=-l){

config.setEnabledAt(index,ie.getStateChange

= =ItemEvent.SELECTED);

}

this.repaint

}

}

public static void main(String args[]){

java3 SC=new java3;

se.setVisible(true);

}

}

1

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

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

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

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

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);

metalButton.addActionListener(this);

motifButton.addActionListener(this);

windowsButton.addActionListener(this);

}

Dublic void actionPerformed(ActionEvent evt)

{Object source=evt.getSource;

String plaf="":

if(source= =metalButton)

plaf="javax.swing.plaf.metal.MetalLookAnd-

Feel";

else if(source= =motifButton)

plaf="com.sun.java.swing.plaf.motif.Moti-

fLookAndFeel";

else if(source= =windowsButton)

Dlaf="com.sun.java.swing.plaf.windows.Win-

dowsLookAndFeel";

try

{UIManager.setLookAndFeel(         );

SwingUtilities.updateComponentTreeUI(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)

{System.exit(O);

}

});

Container contentPane=getContentPane;

contentPane.add(new PlafPanel);

}

}

public class java2

{public static void main(String[]args)

f JFrame. frame=new PlafFrame;

frame.show;

}

1

下列程序片段中,能通过编译的是(  )。

  • A.public abstract class Animal{ public void speak;}
  • B.public abstract class Animal{ public vold speak;}
  • C.public class Animal{ pubilc abstract void speak;}
  • D.public abstract class Animal{ pubilc abstract void speak;}
5

下列叙述中错误的是(  )。

  • A.线性表是由n个元素组成的一个有限序列
  • B.线性表是一种线性结构
  • C.线性表的所有结点有且仅有一个前件和后件
  • D.线性表可以是空表
5

下列关于Applet的安全限制的叙述中,错误的是(  )。

  • A.通常情况下,禁止Applet读、写本地文件系统
  • B.通常情况下,禁止Applet向Applet源主机之外的任何主机建立网络连接
  • C.通常情况下,禁止Applet读取系统信息
  • D.通常情况下,禁止Applet加载本地库或方法
5

下面程序段的输出结果为(  )。

public class Test

{

public static void main(String args[])

{

booleana,b,C;

  • a=(3<5):
  • b=(a= =true);&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("a="+a+"b="+b);
  • c=(b= =false);&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("b="+b+"c="+c);&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;}
  • A.a=true b=false&nbsp;&nbsp;b=true c=true
  • B.a=true b=false&nbsp;&nbsp;b=true c=false
  • C.a=false b=true&nbsp;b=true c=false
  • D.a=false b=false&nbsp;&nbsp;b=true c=false
5

java.io包的File类是(  )。

  • A.字符流类&nbsp;
  • B.字节流类
  • C.对象流类&nbsp;
  • D.非流类