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

上传人:刘芸 文档编号:1338294 上传时间:2019-10-17 格式:DOC 页数:4 大小:36.50KB
下载 相关 举报
【计算机类职业资格】计算机二级JAVA-172 (1)及答案解析.doc_第1页
第1页 / 共4页
【计算机类职业资格】计算机二级JAVA-172 (1)及答案解析.doc_第2页
第2页 / 共4页
【计算机类职业资格】计算机二级JAVA-172 (1)及答案解析.doc_第3页
第3页 / 共4页
【计算机类职业资格】计算机二级JAVA-172 (1)及答案解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、计算机二级 JAVA-172 (1)及答案解析(总分:100.00,做题时间:90 分钟)一、综合应用题(总题数:3,分数:100.00)1.本程序的功能是监听对菜单项和工具条的操作。窗口中有“Color”菜单和一个工具条,“Color”菜单中包括“Yellow”、“Blue”、“Red”和“Exit”菜单项,每个菜单项都有对应的图形,单击前三个颜色菜单项,主窗口就变成对应的颜色,单击“Exit”菜单项则退出程序。工具条上则有四个按钮,分别为三个颜色按钮和一个退出程序的按钮,单击任意一个颜色按钮,主窗口将变成按钮对应的颜色,单击退出程序按钮,则退出程序,如图所示。 (分数:33.00)_2.本

2、程序是一个 Applet,功能是在页面上画比例柱状图。页面中展示了 1998 年 9 个国家的人口数,并以柱状图的方式对各国人口数的多少做了对比,如图所示。 (分数:33.00)_3.本程序的功能是打印出程序所在磁盘下所有目录,方法是将当前目录下的所有目录压入栈,然后弹出一个目录,将该目录下所有的目录压入栈,直到栈空。 import java.io.*; import java.util.*; public class exam_25 public static void main(String args) Stack directoryStack=new Stack(); File root

3、new File(File.separator + “.“); directoryStack.push(root); while ( directoryStack.length() 0 ) File currentDirectory=(File)directoryStack.pop(); System.out.println(currentDirectory); String subdirectories=currentDirectory.list() ; if (subdirectories != null) for (int i=0; i subdirectories.length; i

4、) try String fname =currentDirectory.getCanonicalPath() + File.separator + subdirectoriesi; File f=new File(fname); if (f.isDirectory() directoryStack.pop(f) ; catch(IOException e) System.out.println(e); (分数:34.00)_计算机二级 JAVA-172 (1)答案解析(总分:100.00,做题时间:90 分钟)一、综合应用题(总题数:3,分数:100.00)1.本程序的功能是监听对菜单项和

5、工具条的操作。窗口中有“Color”菜单和一个工具条,“Color”菜单中包括“Yellow”、“Blue”、“Red”和“Exit”菜单项,每个菜单项都有对应的图形,单击前三个颜色菜单项,主窗口就变成对应的颜色,单击“Exit”菜单项则退出程序。工具条上则有四个按钮,分别为三个颜色按钮和一个退出程序的按钮,单击任意一个颜色按钮,主窗口将变成按钮对应的颜色,单击退出程序按钮,则退出程序,如图所示。 (分数:33.00)_正确答案:()解析:第 1 处:contentPane.add(bar, BorderLayout.NORTH) 第 2 处:setJMenuBar(menuBar) 第 3

6、处:panel.setBackground(c)2.本程序是一个 Applet,功能是在页面上画比例柱状图。页面中展示了 1998 年 9 个国家的人口数,并以柱状图的方式对各国人口数的多少做了对比,如图所示。 (分数:33.00)_正确答案:()解析:第 1 处:valuesi = Double.parseDouble 第 2 处:super.paintComponent(g) 第 3 处:Graphics2D g2 = (Graphics2D)g3.本程序的功能是打印出程序所在磁盘下所有目录,方法是将当前目录下的所有目录压入栈,然后弹出一个目录,将该目录下所有的目录压入栈,直到栈空。 im

7、port java.io.*; import java.util.*; public class exam_25 public static void main(String args) Stack directoryStack=new Stack(); File root=new File(File.separator + “.“); directoryStack.push(root); while ( directoryStack.length() 0 ) File currentDirectory=(File)directoryStack.pop(); System.out.printl

8、n(currentDirectory); String subdirectories=currentDirectory.list() ; if (subdirectories != null) for (int i=0; i subdirectories.length; i+) try String fname =currentDirectory.getCanonicalPath() + File.separator + subdirectoriesi; File f=new File(fname); if (f.isDirectory() directoryStack.pop(f) ; catch(IOException e) System.out.println(e); (分数:34.00)_正确答案:()解析:第 1 处:directoryStack.size() 0 第 2 处:String subdirectories = currentDirectory.list() 第 3 处:directoryStack.push(f)

展开阅读全文
相关资源
猜你喜欢
  • ITU-T L 1-1988 Construction Installation and Protection of Telecommunication Cables in Public Networks《在公用网络中通信电缆的结构、安装和保护-电缆及户外设备的其他部分的结构、安装和保护(研究组6)1》.pdf ITU-T L 1-1988 Construction Installation and Protection of Telecommunication Cables in Public Networks《在公用网络中通信电缆的结构、安装和保护-电缆及户外设备的其他部分的结构、安装和保护(研究组6)1》.pdf
  • ITU-T L 10-2015 Optical fibre cables for duct and tunnel application (Study Group 15)《用于管道和隧道应用的光纤电缆(研究组15)》.pdf ITU-T L 10-2015 Optical fibre cables for duct and tunnel application (Study Group 15)《用于管道和隧道应用的光纤电缆(研究组15)》.pdf
  • ITU-T L 1000 SPANISH-2011 Universal power adapter and charger solution for mobile terminals and other hand-held ICT devices.pdf ITU-T L 1000 SPANISH-2011 Universal power adapter and charger solution for mobile terminals and other hand-held ICT devices.pdf
  • ITU-T L 1000-2010 Universal power adapter and charger solution for mobile terminals and other ICT devices (Study Group 5)《移动终端和其它便携式信息通讯技术(ICT)设备的万用电源变压器和充电器方案 5号研究组》.pdf ITU-T L 1000-2010 Universal power adapter and charger solution for mobile terminals and other ICT devices (Study Group 5)《移动终端和其它便携式信息通讯技术(ICT)设备的万用电源变压器和充电器方案 5号研究组》.pdf
  • ITU-T L 1000-2011 Universal power adapter and charger solution for mobile terminals and other hand-held ICT devices (Study Group 5)《(预发布)移动终端和其它便携式信息通讯技术(ICT)设备的万用电源变压器和充电器方案》.pdf ITU-T L 1000-2011 Universal power adapter and charger solution for mobile terminals and other hand-held ICT devices (Study Group 5)《(预发布)移动终端和其它便携式信息通讯技术(ICT)设备的万用电源变压器和充电器方案》.pdf
  • ITU-T L 1002-2016 External universal power adapter solutions for portable information and communication technology devices (Study Group 5)《便携式信息和通信技术设备的外部通用电源适配器解决方案(研究组5)》.pdf ITU-T L 1002-2016 External universal power adapter solutions for portable information and communication technology devices (Study Group 5)《便携式信息和通信技术设备的外部通用电源适配器解决方案(研究组5)》.pdf
  • ITU-T L 1005-2014 Test suites for assessment of the universal charger solution (Study Group 5)《用于评估通用充电器解决方案的测试套件》.pdf ITU-T L 1005-2014 Test suites for assessment of the universal charger solution (Study Group 5)《用于评估通用充电器解决方案的测试套件》.pdf
  • ITU-T L 1006-2016 Test suites for assessment of the external universal power adapter solutions for stationary information and communication technology devices (Study Group 5).pdf ITU-T L 1006-2016 Test suites for assessment of the external universal power adapter solutions for stationary information and communication technology devices (Study Group 5).pdf
  • ITU-T L 1007-2016 Test suites for assessment of the external universal power adapter solutions for portable information and communication technology devices (Study Group 5)《便携式信息和通.pdf ITU-T L 1007-2016 Test suites for assessment of the external universal power adapter solutions for portable information and communication technology devices (Study Group 5)《便携式信息和通.pdf
  • 相关搜索

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

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