计算机的程序填空题,全国计算机等考试二级程序填空题.doc

全国计算机等级考试二级Java捷成模拟上机试题

全部是程序填空题,需要填空的语句用”//”注释了,答案就是该语句后面的语句

1.

"//计算两个整数的乘法

import javax.swing.JOptionPane;

public class Java_1 {

public static void main( String args[] ) {

int x, y, result;

String xVal, yVal;

xVal = JOptionPane.showInputDialog( ""输入第1个整数:"" );

yVal = JOptionPane.showInputDialog( ""输入第2个整数:"" );

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

// x = Integer.parseInt( _____________ );

x = Integer.parseInt( xVal );

y = Integer.parseInt( yVal );

result = x * y;

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

// JOptionPane._________________________( null, ""两个数的积: "" + result );

JOptionPane.showMessageDialog( null, ""两个数的积: "" + result );

System.exit( 0 );

}

}

"

2.

"//用一个打印语句输出多行结果

public class Java_1

{

public static void main( String args[] )

{

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

// _________________________(""欢迎\n你\n参加\nJava\n考试"");

System.out.print(""欢迎\n你\n参加\nJava\n考试"");

}

}

"

3.

"import java.io.*;

public class Java_1 {

public static void main(String[] args) {

char[] charArray = {'a','b','c','d','e','f','g','h','i'};

char c ;

try{

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

// DataOutputStream out = new ______________________(

DataOutputStream out = new DataOutputStream(

new FileOutputStream(""test.dat""));

for(int i =0; i

out.writeChar(charArray[i]);

}

out.close();

DataInputStream in = new DataInputStream(

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

// new FileInputStream(""____________________""));

new FileInputStream(""test.dat""));

while(in.available() != 0){

c=in.readChar();

System.out.print(c+"" "");

}

System.out.println();

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

// in.____________________();

in.close();

}catch(IOException e){}

}

}

"

4.

"import javax.swing.*;

import java.text.DecimalFormat;

public class

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值