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

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

1、计算机二级 JAVA-151 (1)及答案解析(总分:100.00,做题时间:90 分钟)一、简单应用题(总题数:3,分数:100.00)1.本程序的功能是解析 URL,打印出指定 URL 的信息,包括协议、主机名、端口、文件名以及在文件中的相对位置。 _; import java.io.*; public class exam_66 public static void main(String args) try URL urlObj=new URL(“http:/:80/index.html“); String urlPro=urlObj.getProtocol(); String url

2、Host =urlObj.getHost(); int urlPort =_; String fileName=urlObj.getFile(); String urlRef =urlObj.getRef(); System.out. println ( “URL 协议: “+urlPro); System.out.println (“URL 主机名: “+urlHost); System.out.println(“URL 端品:“+urlPort); System. out .println (“URL 文件名: “+fileName); System.out .println (“URL

3、在文件中的相对位置: “+urlRef); catch (MalformedURLException e) (分数:30.00)_2.本程序是一个 Applet,实现了简单的英汉和汉英单词的互查。在页面中有三个文本框,分别为中文单词文本框、英文单词文本框和结果文本框,在英文单词文本框中输入英文单词后回车,如果存在该单词,则在结果文本框中输出对应的中文含义,如果不存在则输出“没有该单词”。同样,在中文单词文本框中输入中文单词后回车,如果查找到对应的英文单词,就在结果文本框中输出,否则输出“没有该单词”,如图所示。 import java.applet.*; import java.awt.*;

4、import java.awt.event.*; public class exam_67 _ TextField text1,text2,text3; Label lab1,lab2,1ab3; public void init () text1=new TextField(10); text2=new TextField(10); text3=new TextField(10); lab1=new Label (“请输入英文单词: “); lab2=new Label (“请输入中文单词:“); lab3=new Label(“结果:“); add (lab1);add (text1);

5、add (lab2); add (text2); add (lab3);add (text3); text1, addActionListener (this); text2, addActionListener (this); public void actionPerformed (ActionEvent e) if(_) String word=text1.getText(); if (word.equals (“boy“) text3.setText (“男孩“); else if (word.equals (“girl“) text3.setText (“女孩“); else if

6、word.equals (“sun“) text3.setText (“太阳“); else text3, setText (“没有该单词“); else if(e.getSource()=text2) String word=text2.getText(); if (word.equals (“男孩“) text3, setText ( “boy“ ); else if (word.equals(“女孩“) text3.setText(“girl“); else if (word.equals(“太阳“) text3.setText (“sun“); else text3.setText

7、没有该单词“); (分数:30.00)_3.本程序是一个 Applet,在页面上有三个文本框,在第一个文本框中输入一个整数后回车,则在第二个文本框中显示该整数的平方,在第三个文本框中显示该整数的立方,如图所示。 (分数:40.00)_计算机二级 JAVA-151 (1)答案解析(总分:100.00,做题时间:90 分钟)一、简单应用题(总题数:3,分数:100.00)1.本程序的功能是解析 URL,打印出指定 URL 的信息,包括协议、主机名、端口、文件名以及在文件中的相对位置。 _; import java.io.*; public class exam_66 public static

8、 void main(String args) try URL urlObj=new URL(“http:/:80/index.html“); String urlPro=urlObj.getProtocol(); String urlHost =urlObj.getHost(); int urlPort =_; String fileName=urlObj.getFile(); String urlRef =urlObj.getRef(); System.out. println ( “URL 协议: “+urlPro); System.out.println (“URL 主机名: “+ur

9、lHost); System.out.println(“URL 端品:“+urlPort); System. out .println (“URL 文件名: “+fileName); System.out .println (“URL 在文件中的相对位置: “+urlRef); catch (MalformedURLException e) (分数:30.00)_正确答案:()解析:第 1 处:import .* 第 2 处:urlObj.getPort()2.本程序是一个 Applet,实现了简单的英汉和汉英单词的互查。在页面中有三个文本框,分别为中文单词文本框、英文单词文本框和结果文本框,

10、在英文单词文本框中输入英文单词后回车,如果存在该单词,则在结果文本框中输出对应的中文含义,如果不存在则输出“没有该单词”。同样,在中文单词文本框中输入中文单词后回车,如果查找到对应的英文单词,就在结果文本框中输出,否则输出“没有该单词”,如图所示。 import java.applet.*; import java.awt.*; import java.awt.event.*; public class exam_67 _ TextField text1,text2,text3; Label lab1,lab2,1ab3; public void init () text1=new TextF

11、ield(10); text2=new TextField(10); text3=new TextField(10); lab1=new Label (“请输入英文单词: “); lab2=new Label (“请输入中文单词:“); lab3=new Label(“结果:“); add (lab1);add (text1); add (lab2); add (text2); add (lab3);add (text3); text1, addActionListener (this); text2, addActionListener (this); public void actionP

12、erformed (ActionEvent e) if(_) String word=text1.getText(); if (word.equals (“boy“) text3.setText (“男孩“); else if (word.equals (“girl“) text3.setText (“女孩“); else if (word.equals (“sun“) text3.setText (“太阳“); else text3, setText (“没有该单词“); else if(e.getSource()=text2) String word=text2.getText(); if

13、 (word.equals (“男孩“) text3, setText ( “boy“ ); else if (word.equals(“女孩“) text3.setText(“girl“); else if (word.equals(“太阳“) text3.setText (“sun“); else text3.setText (“没有该单词“); (分数:30.00)_正确答案:()解析:第 1 处:extends Applet implements ActionListener 第 2 处:e.getSource()=text13.本程序是一个 Applet,在页面上有三个文本框,在第一个文本框中输入一个整数后回车,则在第二个文本框中显示该整数的平方,在第三个文本框中显示该整数的立方,如图所示。 (分数:40.00)_正确答案:()解析:第 1 处:police 第 2 处:a.text3.setText

展开阅读全文
相关资源
猜你喜欢
  • BS EN ISO 11688-1-2009 Acoustics - Recommended practice for the design of low-noise machinery and equipment - Planning《声学 低噪声机器和设备设计的推荐实用规程 计划》.pdf BS EN ISO 11688-1-2009 Acoustics - Recommended practice for the design of low-noise machinery and equipment - Planning《声学 低噪声机器和设备设计的推荐实用规程 计划》.pdf
  • BS EN ISO 11689-1996 Acoustics - Procedure for the comparison of noise-emission data for machinery and equipment《声学 机械和设备发射噪声数据的比较方法》.pdf BS EN ISO 11689-1996 Acoustics - Procedure for the comparison of noise-emission data for machinery and equipment《声学 机械和设备发射噪声数据的比较方法》.pdf
  • BS EN ISO 11690-1-1997 Acoustics Recommended practice for the design of low-noise workplaces containing machinery Noise control strategies《声学 低噪声机器工作间设计的推荐实施规程 噪声控制策略》.pdf BS EN ISO 11690-1-1997 Acoustics Recommended practice for the design of low-noise workplaces containing machinery Noise control strategies《声学 低噪声机器工作间设计的推荐实施规程 噪声控制策略》.pdf
  • BS EN ISO 11690-2-1997 Acoustics Recommended practice for the design of low-noise workplaces containing machinery Noise control measures《声学 低噪声机器工作间设计的推荐实施规程 噪声控制测量》.pdf BS EN ISO 11690-2-1997 Acoustics Recommended practice for the design of low-noise workplaces containing machinery Noise control measures《声学 低噪声机器工作间设计的推荐实施规程 噪声控制测量》.pdf
  • BS EN ISO 11690-3-1999 Acoustics - Recommended practice for the design of low-noise workplaces containing machinery - Sound propagation and noise prediction in workrooms《声学 低噪声机械工作.pdf BS EN ISO 11690-3-1999 Acoustics - Recommended practice for the design of low-noise workplaces containing machinery - Sound propagation and noise prediction in workrooms《声学 低噪声机械工作.pdf
  • BS EN ISO 11691-2009 Acoustics - Measurement of insertion loss of ducted silencers without flow - Laboratory survey method《声学 无气流管道消声器插入损失的测量 实验室测量法》.pdf BS EN ISO 11691-2009 Acoustics - Measurement of insertion loss of ducted silencers without flow - Laboratory survey method《声学 无气流管道消声器插入损失的测量 实验室测量法》.pdf
  • BS EN ISO 11699-1-2011 Non-destructive testing Industrial radiographic film Classification of film systems for industrial radiography《无损检测 工业放射线照片 工业射线照相法用胶片系统的分类》.pdf BS EN ISO 11699-1-2011 Non-destructive testing Industrial radiographic film Classification of film systems for industrial radiography《无损检测 工业放射线照片 工业射线照相法用胶片系统的分类》.pdf
  • BS EN ISO 11699-2-2011 Non-destructive testing Industrial radiographic films Control of film processing by means of reference values《无损检测 工业射线照相胶片 利用参考值方式控制胶片冲洗加工》.pdf BS EN ISO 11699-2-2011 Non-destructive testing Industrial radiographic films Control of film processing by means of reference values《无损检测 工业射线照相胶片 利用参考值方式控制胶片冲洗加工》.pdf
  • BS EN ISO 11701-2009 Vegetable fats and oils - Determination of phospholipids content in lecithins by HPLC using a light-scattering detector《植物脂肪和油脂 利用高效液相色谱法(HPLC)使用光散射检测器测定卵磷脂中的磷.pdf BS EN ISO 11701-2009 Vegetable fats and oils - Determination of phospholipids content in lecithins by HPLC using a light-scattering detector《植物脂肪和油脂 利用高效液相色谱法(HPLC)使用光散射检测器测定卵磷脂中的磷.pdf
  • 相关搜索

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

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