ImageVerifierCode 换一换
格式:DOC , 页数:9 ,大小:39KB ,
资源ID:1326595      下载积分:5000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-1326595.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(【计算机类职业资格】二级JAVA机试-74及答案解析.doc)为本站会员(孙刚)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

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

1、二级 JAVA 机试-74 及答案解析(总分:100.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:30.00)1.本题中,在下画线上填写代码,指定变量 b 为字节型,变量 f 为单精度实型,变量 1 为 64 位整型。public class java1public static void main(Stringargs)_b=49;_f=8.9f;_l=0xfedl;System.out.println(“b=“+b);System.out.println(“f=“+f);System.out.println(“l=“+1);(分数:30.00)_二、简单应用题(总题数:1

2、,分数:40.00)2.本题是一个表格式的成绩单,其中包括“姓名”、“英语成绩”、“数学成绩”和“总成绩”,姓名和成绩都可以进行修改,单击按钮“计算每人总成绩”,则可以统计出每个人的总成绩并显示在总成绩栏中。import javax.swing.*;import java.awt.*;import java.awt.event.*;public class java2 extends JFrame implements ActionListenerJTable table;Object a;Object name=“姓名“,“英语成绩“,“数学成绩“,“总成绩“);JButton button

3、;java2()setTitle(“java2“);a=new Object84;for(int i=0;i8;i+)for(int j=0;j4;j+)if(j!=0)aij=“;elseaij=“;button=new JButton(“计算每人总成绩“);table=_;button.addActionListener(this);getContentPane().add(new JScrollPane(table),BorderLayout.CENTER);getContentPane().add(button,BorderLayout.SOUTH);setSize(400,200);

4、setVisible(true);validate();addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)for(int i=0;i8;i+)double sum=0;boolean boo=true;for(int j=1;j=2;j+)trysum=sum+Double.parseDouble(_);catch(Exception ee)boo=false;table.r

5、epaint();if(boo=true)ai3=“+sum;table.repaint();public static void main(String args)java2 Win=new java2();(分数:40.00)_三、综合应用题(总题数:1,分数:30.00)3.本题中,通过菜单“Connect”显示一个对话框,单击“ok”按钮后,所填写的内容就会传回到主窗口并显示出来。import java.awt.*;import java.awt.event.*;import javax.swing.*;public class java3 extends JFrame impleme

6、nts ActionListenerpublic java3()setTitle(“java3“);setSize(300,300);addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););JMenuBar mbar=new JMenuBar();setJMenuBar(bar);JMenu fileMenu=new JMenu(“File“);mbar.add(fileMenu);connectItem=new JMenuItem(“Connect“);conn

7、ectItem.addActionListener(this);fileMenu.add(connectItem);exitItem=new JMenuItem(“Exit“);exitItem.addActionListener(this);fileMenu.add(exitItem);public void actionPerformed(ActionEvent evt)Object source=evt.getSource();if(source=connectItem)ConnectInfo transfer=new ConnectInfo(“yourname“,“pw“);if(di

8、alog=null)dialog=new ConnectDialog(this);if(dialog.showDialog(transfer)String uname=transfer.username;String pwd=transfer.password;Container contentPane=getContentPane();contentPane.add(new JLabel(“username=“+uname+“,password=“+pwd),“South“);validate();else if(source=exitItem)System.exit(0);public s

9、tatic void main(Stringargs)JFrame f=new java3();f.show();private ConnectDialog dialog=null;private JMenuItem connectItem;private JMenuItem exitItem;class ConnectInfopublic String username;public String password;public Connectfnfo(String u,String p)username=u;password=p;class ConnectDialog extends JD

10、ialog implements ActionListenerpublic ConnectDialog()super(parent,“Connect“,true);Container contentPane=getContentPane();JPanel p1=new JPanel();p1.setLayout(new GridLayout(2,2);p1.add(new JLabel(“User name:“);p1.add(username=new JTextField(“);p1.add(new JLabel(“Password:“);p1.add(password=new JPassw

11、ordField(“);contentPane.add(“Center“,p1);Panel p2=new Panel();okButton=addButton(p2,“Ok“);cancelButton=addButton(p2,“Cancel“);contentPane.add(“South“,p2);setSize(240,120);JButton addButton(Container c,String name)JButton button=new JButton(name);button.addActionListener(this);c.add(button);return bu

12、tton;public void actionPerformed(ActionEvent evt)Object source=evt.getSource();if(source=okButton)ok=true;setVisible(false);else if(source=cancelButton)setVisible(false);public void showDialog(ConnectInfo transfer)username.setText(transfer.username);password.setText(transfer.password);ok=false;show(

13、);if(ok)transfer.username=username.getText();transfer.password=new String(password.getPassword();return ok;private JTextField username;private JPasswordField password;private boolean ok;private JButton okButton;private JButton cancelButton;(分数:30.00)_二级 JAVA 机试-74 答案解析(总分:100.00,做题时间:90 分钟)一、基本操作题(总

14、题数:1,分数:30.00)1.本题中,在下画线上填写代码,指定变量 b 为字节型,变量 f 为单精度实型,变量 1 为 64 位整型。public class java1public static void main(Stringargs)_b=49;_f=8.9f;_l=0xfedl;System.out.println(“b=“+b);System.out.println(“f=“+f);System.out.println(“l=“+1);(分数:30.00)_正确答案:(第 1 处:byte第 2 处:float第 3 处:long)解析:解析 本题考查的是数据类型。byte 为字节

15、型;float 为单精度实型;long 为长整型。二、简单应用题(总题数:1,分数:40.00)2.本题是一个表格式的成绩单,其中包括“姓名”、“英语成绩”、“数学成绩”和“总成绩”,姓名和成绩都可以进行修改,单击按钮“计算每人总成绩”,则可以统计出每个人的总成绩并显示在总成绩栏中。import javax.swing.*;import java.awt.*;import java.awt.event.*;public class java2 extends JFrame implements ActionListenerJTable table;Object a;Object name=“姓

16、名“,“英语成绩“,“数学成绩“,“总成绩“);JButton button;java2()setTitle(“java2“);a=new Object84;for(int i=0;i8;i+)for(int j=0;j4;j+)if(j!=0)aij=“;elseaij=“;button=new JButton(“计算每人总成绩“);table=_;button.addActionListener(this);getContentPane().add(new JScrollPane(table),BorderLayout.CENTER);getContentPane().add(button

17、,BorderLayout.SOUTH);setSize(400,200);setVisible(true);validate();addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)for(int i=0;i8;i+)double sum=0;boolean boo=true;for(int j=1;j=2;j+)trysum=sum+Double.parseDouble(_

18、);catch(Exception ee)boo=false;table.repaint();if(boo=true)ai3=“+sum;table.repaint();public static void main(String args)java2 Win=new java2();(分数:40.00)_正确答案:(第 1 处:new JTable(a,name)第 2 处:aij.toString()解析:解析 第 1 处初始化表格变量;第 2 处取得表格中单元格内容并转换成 Double 型计算出总成绩。三、综合应用题(总题数:1,分数:30.00)3.本题中,通过菜单“Connect”

19、显示一个对话框,单击“ok”按钮后,所填写的内容就会传回到主窗口并显示出来。import java.awt.*;import java.awt.event.*;import javax.swing.*;public class java3 extends JFrame implements ActionListenerpublic java3()setTitle(“java3“);setSize(300,300);addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0)

20、;);JMenuBar mbar=new JMenuBar();setJMenuBar(bar);JMenu fileMenu=new JMenu(“File“);mbar.add(fileMenu);connectItem=new JMenuItem(“Connect“);connectItem.addActionListener(this);fileMenu.add(connectItem);exitItem=new JMenuItem(“Exit“);exitItem.addActionListener(this);fileMenu.add(exitItem);public void a

21、ctionPerformed(ActionEvent evt)Object source=evt.getSource();if(source=connectItem)ConnectInfo transfer=new ConnectInfo(“yourname“,“pw“);if(dialog=null)dialog=new ConnectDialog(this);if(dialog.showDialog(transfer)String uname=transfer.username;String pwd=transfer.password;Container contentPane=getCo

22、ntentPane();contentPane.add(new JLabel(“username=“+uname+“,password=“+pwd),“South“);validate();else if(source=exitItem)System.exit(0);public static void main(Stringargs)JFrame f=new java3();f.show();private ConnectDialog dialog=null;private JMenuItem connectItem;private JMenuItem exitItem;class Conn

23、ectInfopublic String username;public String password;public Connectfnfo(String u,String p)username=u;password=p;class ConnectDialog extends JDialog implements ActionListenerpublic ConnectDialog()super(parent,“Connect“,true);Container contentPane=getContentPane();JPanel p1=new JPanel();p1.setLayout(n

24、ew GridLayout(2,2);p1.add(new JLabel(“User name:“);p1.add(username=new JTextField(“);p1.add(new JLabel(“Password:“);p1.add(password=new JPasswordField(“);contentPane.add(“Center“,p1);Panel p2=new Panel();okButton=addButton(p2,“Ok“);cancelButton=addButton(p2,“Cancel“);contentPane.add(“South“,p2);setS

25、ize(240,120);JButton addButton(Container c,String name)JButton button=new JButton(name);button.addActionListener(this);c.add(button);return button;public void actionPerformed(ActionEvent evt)Object source=evt.getSource();if(source=okButton)ok=true;setVisible(false);else if(source=cancelButton)setVis

26、ible(false);public void showDialog(ConnectInfo transfer)username.setText(transfer.username);password.setText(transfer.password);ok=false;show();if(ok)transfer.username=username.getText();transfer.password=new String(password.getPassword();return ok;private JTextField username;private JPasswordField

27、password;private boolean ok;private JButton okButton;private JButton cancelButton;(分数:30.00)_正确答案:(第 1 处:setJMenuBar(mbar)第 2 处:public ConneetDialog(JFrame parent)第 3 处:public Boolean showDialog(ConnectInfotransfer)解析:解析 第 1 处参数错误,bar 未定义;第 2 处从下一行的 super(parent,“Connect“,true);可以看出,这里需要的参数为父窗体;第 3 处从下面的 return ok;等可以看出,这是一个有 Boolean 型返回值的函数,故类型应为 Boolean。

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