【计算机类职业资格】计算机二级JAVA-150及答案解析.doc

上传人:sumcourage256 文档编号:1338249 上传时间:2019-10-17 格式:DOC 页数:8 大小:39KB
下载 相关 举报
【计算机类职业资格】计算机二级JAVA-150及答案解析.doc_第1页
第1页 / 共8页
【计算机类职业资格】计算机二级JAVA-150及答案解析.doc_第2页
第2页 / 共8页
【计算机类职业资格】计算机二级JAVA-150及答案解析.doc_第3页
第3页 / 共8页
【计算机类职业资格】计算机二级JAVA-150及答案解析.doc_第4页
第4页 / 共8页
【计算机类职业资格】计算机二级JAVA-150及答案解析.doc_第5页
第5页 / 共8页
点击查看更多>>
资源描述

1、计算机二级 JAVA-150 及答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:30.00)1.本题中定义了长度为 20 的一维整型数组 a,并将数组元素的下标值赋给数组元素,最后打印输出数组中下标为奇数的元素。 public class java1( public static void main(Stringargs) int a=_; int i; for(_;i+) ai=i; for(i=0;i20;i+) if(_) System.out.print(“a“+i+“=“+ai+“,“); (分数:30.00)_二、2简单应用题(总题数:1,分

2、数:40.00)2.本题程序的功能是主窗口有一个按钮、一个文本域和一个复选框,初始时窗口的大小是不能调整的,勾选复选框后,窗口大小就可以进行调整,如果取消勾选复选框,则窗口的大小又不能调整,单击按钮可以关闭程序。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。 import java.awt.*; import java.awt.event.*; class MyFrame extends Frame_ Checkbox box; TextArea text; Button button; MyFrame(String s) super (s); box = new Chec

3、kbox(“设置窗口是否可调整大小“); text = new TextArea(12,12); button = new Button(“关闭窗口“); button.addActionListener(this); box.addItemListener(this); setBounds(100,100,200,300); setVisible(true); add(text,BorderLayout.CENTER); add(box,BorderLayout.SOUTH); add(button,BorderLayout.NORTH); _; validate (); public vo

4、id itemStateChanged(ItemEvent e) if (box.getState() = true) setResizable(true); else setResizable(false); public void actionPerformed(ActionEvent e) dispose(); class simple public static void main(String args) new MyFrame(“simple“); (分数:40.00)_三、3综合应用题(总题数:1,分数:30.00)3.本题程序的功能是求两个交叉图形的并、减、交及异或。窗口中有

5、4 个单选按钮和一个图形面板,面板中有两个交叉的图形,选中其中一个单选按钮,图形面板中会以黑色填充的方式显示运算的结果。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。 import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.util.*; import javax.swing.*; public class advance public static void main(String args) JFrame frame = new AreaTestFrame(); fr

6、ame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.show(); class AreaTestFrame extends JFrame public AreaTestFrame() setTitle(“advance“); setSize(WIDTH,HEIGHT); area1 = new Area(new Ellipse2D.Double(100,100,150,100); area2 = new Area(new Rectangle2D.Double(150,150,150,100); _; panel = new JPa

7、nel() public void paintComponent(Graphics g) super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.draw(area1); g2.draw(area2); if (area ! = null) g2.fill(area); contentPane.add(panel,BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); ButtonGroup group = new ButtonGroup(); JRadioButton ad

8、dButtoh = new JRadioButton(“并“,false); buttonPanel.add(addButton); group.add(addButton); addButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent event) area = new Area(); area.add(area1); area.add(area2); panel.repaint(); ); JRadioButton subtractButton = new JRadioBu

9、tton(“减“,false); buttonPanel.add(subtractButton); group.add(subtractButton); subtractButton.addActionListener(new ActienListener() public void actionPerformed(ActionEvent event) area = new Area(); area.add(areal); _; panel.repaint(); ); JRadioButton intersectButton = new JRadioButton(“交“,false); but

10、tonPanel.add(intersectButton); group.add(intersectButton); intersectButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent event) area = new Area(); area.add(area1); area.intersect(area2); panel.repaint(); ); JRadioButten exclusiveOrButton = new JRadioButton(“异或“,false

11、); buttonPanel.add(exclusiveOrButton); group.add(exclusiveOrButton); exclusiveOrButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent event) area = new Area(); area.add(area1); _; panel,repaint (); ); contentPane.add(buttonPanel,BorderLayout.NORTH); private JPanel pan

12、e1; private Area area; private Area area1; private Area area2; private static final int WIDTH = 400; private static final int HEIGHT = 400; (分数:30.00)_计算机二级 JAVA-150 答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:30.00)1.本题中定义了长度为 20 的一维整型数组 a,并将数组元素的下标值赋给数组元素,最后打印输出数组中下标为奇数的元素。 public class java1( pub

13、lic static void main(Stringargs) int a=_; int i; for(_;i+) ai=i; for(i=0;i20;i+) if(_) System.out.print(“a“+i+“=“+ai+“,“); (分数:30.00)_正确答案:()解析:第 1 处:new int20 第 2 处:i=0;i20 第 3 处:i%2! =0 解析 第 1 处定义了长度为 20 的一维整型数组 a;第 2 处的 for 循环将数组元素的下标值赋给数组元素;第 3 处判断数组各个元素下标是否为奇数。二、2简单应用题(总题数:1,分数:40.00)2.本题程序的功能是

14、主窗口有一个按钮、一个文本域和一个复选框,初始时窗口的大小是不能调整的,勾选复选框后,窗口大小就可以进行调整,如果取消勾选复选框,则窗口的大小又不能调整,单击按钮可以关闭程序。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。 import java.awt.*; import java.awt.event.*; class MyFrame extends Frame_ Checkbox box; TextArea text; Button button; MyFrame(String s) super (s); box = new Checkbox(“设置窗口是否可调整大小“

15、); text = new TextArea(12,12); button = new Button(“关闭窗口“); button.addActionListener(this); box.addItemListener(this); setBounds(100,100,200,300); setVisible(true); add(text,BorderLayout.CENTER); add(box,BorderLayout.SOUTH); add(button,BorderLayout.NORTH); _; validate (); public void itemStateChange

16、d(ItemEvent e) if (box.getState() = true) setResizable(true); else setResizable(false); public void actionPerformed(ActionEvent e) dispose(); class simple public static void main(String args) new MyFrame(“simple“); (分数:40.00)_正确答案:()解析:implements ItemListener,ActionListener。 setResizable(false)。三、3综

17、合应用题(总题数:1,分数:30.00)3.本题程序的功能是求两个交叉图形的并、减、交及异或。窗口中有 4 个单选按钮和一个图形面板,面板中有两个交叉的图形,选中其中一个单选按钮,图形面板中会以黑色填充的方式显示运算的结果。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。 import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.util.*; import javax.swing.*; public class advance public static void main

18、(String args) JFrame frame = new AreaTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.show(); class AreaTestFrame extends JFrame public AreaTestFrame() setTitle(“advance“); setSize(WIDTH,HEIGHT); area1 = new Area(new Ellipse2D.Double(100,100,150,100); area2 = new Area(new Rec

19、tangle2D.Double(150,150,150,100); _; panel = new JPanel() public void paintComponent(Graphics g) super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.draw(area1); g2.draw(area2); if (area ! = null) g2.fill(area); contentPane.add(panel,BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); Bu

20、ttonGroup group = new ButtonGroup(); JRadioButton addButtoh = new JRadioButton(“并“,false); buttonPanel.add(addButton); group.add(addButton); addButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent event) area = new Area(); area.add(area1); area.add(area2); panel.repa

21、int(); ); JRadioButton subtractButton = new JRadioButton(“减“,false); buttonPanel.add(subtractButton); group.add(subtractButton); subtractButton.addActionListener(new ActienListener() public void actionPerformed(ActionEvent event) area = new Area(); area.add(areal); _; panel.repaint(); ); JRadioButto

22、n intersectButton = new JRadioButton(“交“,false); buttonPanel.add(intersectButton); group.add(intersectButton); intersectButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent event) area = new Area(); area.add(area1); area.intersect(area2); panel.repaint(); ); JRadioBu

23、tten exclusiveOrButton = new JRadioButton(“异或“,false); buttonPanel.add(exclusiveOrButton); group.add(exclusiveOrButton); exclusiveOrButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent event) area = new Area(); area.add(area1); _; panel,repaint (); ); contentPane.add

24、(buttonPanel,BorderLayout.NORTH); private JPanel pane1; private Area area; private Area area1; private Area area2; private static final int WIDTH = 400; private static final int HEIGHT = 400; (分数:30.00)_正确答案:()解析:Container contentPane = getContentPane()。 area.subtract(area2)。 area.exclusiveOr(a rea2)。

展开阅读全文
相关资源
猜你喜欢
  • CSN 26 0383-1990 Conveyor belts with textile plies for mining Technical requirements《地下用带织物架的传送带 技术要求》.pdf CSN 26 0383-1990 Conveyor belts with textile plies for mining Technical requirements《地下用带织物架的传送带 技术要求》.pdf
  • CSN 26 0605-1994 Continuous mechanical handling equipment Safety code for belt conveyors Examples for guarding of nip points《持续性搬运设备 带式传送机安全规则 咬入口维护范例》.pdf CSN 26 0605-1994 Continuous mechanical handling equipment Safety code for belt conveyors Examples for guarding of nip points《持续性搬运设备 带式传送机安全规则 咬入口维护范例》.pdf
  • CSN 26 0606-1994 Continuous mechanical handling equipment Safety code for belt conveyors Examples for protektion of pinch points on idlers《持续性搬运设备 带式传送机安全规则 惰轮夹点的保护范例》.pdf CSN 26 0606-1994 Continuous mechanical handling equipment Safety code for belt conveyors Examples for protektion of pinch points on idlers《持续性搬运设备 带式传送机安全规则 惰轮夹点的保护范例》.pdf
  • CSN 26 0607-1994 Continuous mechanical handling equipment Safety code for conveyors and elevators with chain-elements Examples for guarding of nip points《持续性搬运设备 带链单元的运货机与升降机安全规则 咬.pdf CSN 26 0607-1994 Continuous mechanical handling equipment Safety code for conveyors and elevators with chain-elements Examples for guarding of nip points《持续性搬运设备 带链单元的运货机与升降机安全规则 咬.pdf
  • CSN 26 0608-1994 Continuous mechanical handling equipment Chain conveyors with bearing devices or load carriers Examples of protection against injuries by load carriers《持续性搬运设备 带承载.pdf CSN 26 0608-1994 Continuous mechanical handling equipment Chain conveyors with bearing devices or load carriers Examples of protection against injuries by load carriers《持续性搬运设备 带承载.pdf
  • CSN 26 2008-1993 Vertical bucket elevators General characteristics and dimensions《垂直链斗升降机 主要特点与尺寸》.pdf CSN 26 2008-1993 Vertical bucket elevators General characteristics and dimensions《垂直链斗升降机 主要特点与尺寸》.pdf
  • CSN 26 3007-1993 Continuous mechanical handling equipment for loose bulk materials Belt conveyors Series of basic parameters and dimensions《散装物料用连续续机械搬运设备 带式运输机 基本参数及尺寸系列》.pdf CSN 26 3007-1993 Continuous mechanical handling equipment for loose bulk materials Belt conveyors Series of basic parameters and dimensions《散装物料用连续续机械搬运设备 带式运输机 基本参数及尺寸系列》.pdf
  • CSN 26 3016-1990 Belt conveyors Methods of testing《带式运输机 测试》.pdf CSN 26 3016-1990 Belt conveyors Methods of testing《带式运输机 测试》.pdf
  • CSN 26 4501-1994 Roller conveyors and wheel conveyors Basic parameters and dimensions《滚筒搬运机及有轮搬运机 基本参数和尺寸》.pdf CSN 26 4501-1994 Roller conveyors and wheel conveyors Basic parameters and dimensions《滚筒搬运机及有轮搬运机 基本参数和尺寸》.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1