首页 > 软考
题目内容 (请给出正确答案)
[主观题]

以下程序的输出结果为()。import math s=0 for i in range(1,10+1): m=int(math.sqrt(i) ) if

以下程序的输出结果为()。import math s=0 for i in range(1,10+1): m=int(math.sqrt(i) ) if m%2==0: continue s=s+i print(s)

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“以下程序的输出结果为()。import math s=0 f…”相关的问题
第1题
(11 )下面程序运行时输出结果为C:\Program Files is a directory请将程序补充完整。import Java.i

(11 )下面程序运行时输出结果为

C:\Program Files is a directory

请将程序补充完整。

import Java.io.*;

public class DirTest{

public static void main(String[] args){

File myDir = new File(" C:/Program Files/ " );

System.out.println

(myDir + (【 11 】 .isDirectory() ? " is " : " is not " ) + " a directory. " );

}

}

点击查看答案
第2题
阅读下面程序 import javax.swing.JOptionPane; public class Comparison{ public static void m

阅读下面程序

import javax.swing.JOptionPane;

public class Comparison{

public static void main(String args[]){

String firstNumber, //用户输入第1个数据变量

second Number, //用户输入第2个数据变量

result; //输出结果变量

int number1, //用于比较的第1个数

number2; //用于比较的第2个数

//用户输入第1个数据的字符串

firstNumber=JOptionPane. showInputDialog(“输入第1个整数:”);

//用户输入第2个数据的字符串

secondNumber=JOptionPane.showlnputDialog(“输入第2个整数:”);

//将字符串转换为整数类型

number1=Integer.parseInt(firstNumber);

number2=Integer.parseInt(secondNumber);

//初始化结果变量

___________________;

//比较两个数据

if(number1=number2)

result += number1 +" =" + number2;

if(number1 != number2 )

result += numberl +" !=" + number2;

if(number1 < number2 )

result = result + "\n" + numberl +" <" + number2;

if(number1 > number2 )

result = result + "\n" + number1 + ">" + number2;

if(number1 <= number2 )

result = result + "\n" + number1 +" <=" + number2;

if (number1 >= number2 )

result = result + "\n" + number1 + ">=" + number2;

//显示结果

JOptionPane.showMessageDialog(null,result," 比较结果",

JOptionPane. INFORMATION_MESSAGE);

System.exit(0);

}

}

为使程序能正确运行并得到合理的输出结果,初始化结果变量语句(下划线处)应是

A.result = ""

B.result = null

C.result = number1

D.result = number2

点击查看答案
第3题
(20 )阅读下面程序import javax.swing.JOptionPane;public class Comparison {public static vo

(20 )阅读下面程序

import javax.swing.JOptionPane;

public class Comparison {

public static void main(String args[] ){

String firstNumber, // 用户输入第 1 个数据变量

secondNumber, // 用户输入第 2 个数据变量

result; // 输出结果变量

int number1, // 用于比较的第 1 个数

number2; // 用于比较的第 2 个数

// 用户输入第 1 个数据的字符串

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

// 用户输入第 2 个数据的字符串

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

// 将字符串转换为整数类型

number1 = Integer.parseInt(firstNumber );

number2 = Integer.parseInt(secondNumber );

// 初始化结果变量

______________________;

// 比较两个数据

if (number1 == number2 )

result += number1 + " == " + number2;

if (number1 != number2 )

result += number1 + " != " + number2;

if (number1 < number2 )

result = result + "\n" + number1 + " < " + number2;

if (number1 > number2 )

result = result + "\n" + number1 + " > " + number2;

if (number1 <= number2 )

result = result + "\n" + number1 + " <= " + number2;

if (number1 >= number2 )

result = result + "\n" + number1 + " >= " + number2;

// 显示结果

JOptionPane.showMessageDialog(null,result," 比较结果 ",

JOptionPane.INFORMATION_MESSAGE );

System.exit(0 );

}

}

为使程序能正确运行并得到合理的输出结果,初始化结果变量语句 (下划线处 ) 应是

A ) result = ""

B ) result = null

C ) result = number1

D ) result = number2

点击查看答案
第4题
【说明】 下面是一个Applet程序,程序的功能是在显示面板上输出字符串。当html页面被其他窗口遮挡后

【说明】

下面是一个Applet程序,程序的功能是在显示面板上输出字符串。当html页面被其他窗口遮挡后再次显示时,请给出输出结果。

import java.awt.*;

import java. (1). *;

public class MyApplet (2) Applet {

public void (3) (Graphics g) {

g.drawString(tip,20,40);

tip ="I am Java Applet";

}

public void init() {

tip ="welcome"; }

private (4) tip;

}

<html>

<head>

<title> A Simple Applet </title>

</head>

<body>

<applet code="MyApplet.class" width=800 height=400>

</applet>

</body>

</html>

网页输出 (5)

点击查看答案
第5题
阅读以下说明和Java代码,填补空缺。[说明] java.util库中提供了Vector模板类,可作为动态数组使用,

阅读以下说明和Java代码,填补空缺。

[说明]

java.util库中提供了Vector模板类,可作为动态数组使用,并可容纳任意数据类型。

该类的部分方法说明如下所示:

方法名 含义

add(k) 向vector对象的尾部添加一个元素k

removeElementAt(i) 删除序号为i的元素(vector元素序号从0开始)

isEmpty() 判断vector对象是否含有元素

size() 返回vector对象中所包含的元素个数

[Java代码]

Import ________;

public class JavaMain {

static private final int ________ =6;

public static void main(String[]args) {

Vector theVector=new Vector< _______ >();

//初始化theVector,将theVector的元素设置为0至5

for(int cEachItem=0; cEachItem<ARRAY_SIZE; cEachItem++)

theVector. add(________ );

showVector(theVector); //依次输出theVector巾的元素

theVector. removeElementAt(3);

showVector(theVector);

}

public static void showVector(Vector theVector){

if(theVector. isEmpty()){

System.out.printin("theVector is empty.");

return;

}

for(int loop=0; loop<theVector.size(); loop++) {

System.out.print(theVector.get(loop));

System.out.print(",");

}

System.out.printin();

}

}

该程序运行后的输出结果为:

0, 1, 2, 3, 4, 5

___________

点击查看答案
第6题
下列程序中,若从键盘中输入的是大写字母C,则程序输出的结果是import java.io.*;public class Exa

下列程序中,若从键盘中输入的是大写字母C,则程序输出的结果是 import java.io.*; public class Exam{ public static void main(String args[]) int ch=0; System.out.println(”输入一个字符:”); try{ ch=System.in.read(); char ch_A='A',ch_Z='Z',; int delta_c=(int)ch_A+(int)ch_Z-ch; System.out.println(”编码后的字符为:”+(char)delta_c); } catch(IOException e){ e.printStackTrace(); } } }

A.C

B.Y

C.X

D.字母C的ASCII码的整型值

点击查看答案
第7题
以下程序行的输出结果为?System.out.println(010|4);

A.14

B.0

C.6

D.12

点击查看答案
第8题
【Java代码】import Java.util.ArrayList;import java.util.List; (1) class AbstractFile{ protec

【Java代码】

import Java.util.ArrayList;

import java.util.List;

(1) class AbstractFile{

protected String name;

public void printName(){System.out.println(name);}

public abstract boolean addChild(AbstractFile file);

public abstract boolean removeChild(AbstractF ile file);

public abstract List<AbstractFile> getChildren();

class File extends AbstractFile{

public File(String name){this.name=name;}

public boolean addChild(AbstractFile file){return false;}

public boolean removeChild(AbstractFile file){return false;}

public List<AbstractFile> getChildren(){return (2) ;}

class Folder extends AbstractFile{

private List <AbslractFile> childList;

public Folder(String name){

this.name=name;

this.childList=new ArrayList<AbstractFile>();

public boolean addChild(AbstractFile file) { return childList.add(file);}

public boolean removeChild(AbstractFile file){return childList.remove(file);}

public (3) <AbstractFile> getChildren(){return (4) ;}

public class Client{

public static void main(String[] args){

//构造一个树形的文件/目录结构

AbstractFile rootFolder= new Folder("c:\\ ");

AbstractFile compositeFolder=new Folder("composite");

AbstractFile windowsFolder=new Folder("windows");

AbstractFile file=new File("TestComposite.java");

rootFolder.addChild(compositeFolder) ;

rootFolder.addChild(windowsFolder);

compositeFolder.addChild(file) ;

//打印目录文件树

printTree(rootFolder);

private static void printTree(AbslractFile ifile){

ifile.printName();

List <AbslractFile> children=ifile.getChildreno:

if(children==null) return;

for (AbstractFile file:children) {

(5) ;

}

该程序运行后输出结果为:

c:\

composite

TestComposite.java

Windows

点击查看答案
第9题
当变量x=2,y=5时,以下程序的输出结果为 Do Until y>5 x=x*y y=y+1LoopPrint xA.2B.5C.10D.20

当变量x=2,y=5时,以下程序的输出结果为 Do Until y>5 x=x*y y=y+1 Loop Print x

A.2

B.5

C.10

D.20

点击查看答案
第10题
编译运行以下程序后,关于输出结果的说明正确的是()。 public class Conditional{ public static

编译运行以下程序后,关于输出结果的说明正确的是()。 public class Conditional{ public static void main (String args[]){ int x=2: System.out.println("value is”+ ((x<1)?2:2)); } }

A.输出结果为:valueis22.2

B.输出结果为:value is 2

C.输出结果为:value is 2.0

D.编译错误

点击查看答案
第11题
以下程序段的输出结果为______。X=1Y=4Do Until Y>4X=K*YY+Y+1LoopPrint XA.1B.4C.8D.20

以下程序段的输出结果为______。 X=1 Y=4 Do Until Y>4 X=K*Y Y+Y+1 Loop Print X

A.1

B.4

C.8

D.20

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改