77范文网 - 专业文章范例文档资料分享平台

二级java考试真题(1)(4)

来源:网络收集 时间:2019-03-27 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

public class Java_3 { private static JLabel lbl; private static JTextArea txt;

public static void main(String[] args) {

JFrame frame=new JFrame(\全国计算机等级考试\

lbl=new JLabel(\ txt=new JTextArea(\

frame.getContentPane().add(txt,BorderLayout.CENTER ); frame.getContentPane().add(lbl,BorderLayout.SOUTH ) ; //*************Found***************** frame._

addWindowListener_____(new

WindowHandler()) ;//注册监听器

WindowHandler

//*************Found***************** txt.addMouseMotionListener(new ______(){ public void mouseMoved(MouseEvent e) {

String strTemp;

strTemp=\当前鼠标位置:(\ //*************Found**************** lbl._ setText_____(strTemp);//显示出鼠标位置 } }) ;

frame.setSize(200,150) ; frame.show() ; } }

class WindowHandler implements WindowListener {

public void windowOpened(WindowEvent e) {} public void windowClosing(WindowEvent e) {System.exit(0) ;}

public void windowClosed(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowActivated(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} }

第八套:

1. import javax.swing.*; import java.awt.event.*;

import java.awt.*; public class Java_1 {

public static void main(String[] args) {

JFrame frame=new JFrame(\全国计算机等级考试\

JButton btnExit=new JButton(\退出(X)\ btnExit.setMnemonic(KeyEvent.VK_X ) ;

btnExit.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

//***************Found************** System.__ exit____(0) ;//退出 } }) ;

Container con=frame.getContentPane(); //**************Found*************

con.__add____(btnExit,BorderLayout.NORTH ) ;//退出按钮加入窗体中

//*************Found****************

frame.__setSize____(200,150) ;//设置窗体的大小为宽200,高150 //*************Found**************** frame.__show____() ;//显示窗体

} }

2. import java.io.*;

public class Java_2 {

public static void main(String args[]) {

int arrScore[][]={{72,83,56,92,67},

{72,84,76,54,89},{94,87,75,68,75},{82,85,78,90,93}}; int nSum;

nSum=0;

//********Found***********

for(int i=0;i

//*********Found***********

for(int j=0;j<__arrScore____.length;j++) {

//*********Found********** __nSum+=____arrScore[i][j]; }

System.out.println(\ } }

3. import java.awt.*; import java.awt.event.*; import java.applet.*; import java.net.URL;

public class Java_3 extends Applet{ private Image im; public void init() {

String strImg;

//***************Found*************

strImg=__getParameter____(\得到参数Image的值 URL url=getDocumentBase() ; im=getImage(url,strImg);

//***************Found****************

this.addMouseMotionListener(new __MouseMotionAdapter____() {

public void mouseMoved(MouseEvent e) {

String strTemp;

strTemp=\鼠标位置:(\ //***********Found***********

showStatus______(strTemp);//在状态栏显示鼠标位置 } }) ; }

public void paint(Graphics g) {

//************Found************

g._ drawImage_____(im,0,0,this) ;//显示出图片

} }

第九套:

1.public class Java_1 {

public static void main(String[] args) { int nSum ; nSum=0;

//*************Found**************** for(int i=0;i

{

System.out.println(\第\个参数值为:\ try {

//************Found*************

__nSum+____=Integer.parseInt(args[i]) ;//将所有参数进行求和 }

catch(Exception e) { } }

//***************Found****************

System.out.println(\商为:\args.length

_______ );//求出所有参数的平

均值 } }

2. import java.applet.*; import java.awt.*;

import java.awt.event.*; import javax.swing.*;

public class Java_2 extends Applet {

public void init() {

ButtonGroup btnGroup=new ButtonGroup();

JRadioButton radioBtn1=new JRadioButton(\二级Java\ JRadioButton radioBtn2=new JRadioButton(\二级C++\ //将单选按钮加入到按钮组中 btnGroup.add(radioBtn1); btnGroup.add(radioBtn2);

//注册单选按钮的事件监听

//*************Found*************

radioBtn1.addItemListener(new _ItemHandler_____()) ; //*************Found*************

radioBtn2.addItemListener(new ___ ItemHandler ___()) ;

this.add(radioBtn1) ; this.add(radioBtn2); } }

class ItemHandler implements ItemListener {

public void itemStateChanged(ItemEvent e) {

if(e.getStateChange()==ItemEvent.SELECTED ) {

String strTemp;

//*************Found***************

JRadioButton radioBtn=(__ JRadioButton ____)e.getItem() ; //*************Found***************

strTemp=\你选择的科目是:\ getText ____() ;//得到按钮的标题 //**************Found**************

JOptionPane._ showMessageDialog _____(null,strTemp) ;//显示出用户选择 } } }

3. import javax.swing.*; import java.awt.*;

import java.awt.event.*;

public class Java_3 {

public static void main(String[] args) {

FrameExame frame=new FrameExame(); } }

class FrameExame extends JFrame {

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库二级java考试真题(1)(4)在线全文阅读。

二级java考试真题(1)(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/547035.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: