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

2019-03-27 23:00

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 {


二级java考试真题(1)(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:低压配电柜的特点、安装及调试 - secret

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: