当前位置:首页计算机类软件水平考试初级程序员->阅读以下说明和Java代码,将应填入(n)处的字句写在答题纸

阅读以下说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。

【说明】

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

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

  方法名         含义

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

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

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

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

【Java 代码】

 import (1) ;

 public class JavaMain {

  static private final int (2) = 6;

  public static void main(String[] args){

  Vector<Integer> theVector = new Vector< (3) >();

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

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

  theVector.add( (4) );

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

   theVector.removeElementAt(3);

  showVector(theVector);

  }

  public static void showVector(Vector<Integer> theVector){

   if (theVector.isEmpty()) {

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

   return;

   }

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

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

   System.out.print(", ");

   }

   System.out.println();

   }

  }

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

查看答案 纠错
答案:
本题解析:

(1)java.util.Vector,或java.util.* (2) ARRAY_SIZE (3)Integer

(4) cEachItem     (5)0,1,2,4,5

本题主要考查Java语言的基本使用和类库的应用。

在使用Java库中所提供的类时,一般需要导入该类库所处的包。所以,空(1)需要填入Vector类所在的包。空(2)处主要考查变量在使用前需要先定义的基本概念,后续的代码中使用了ARRAY_SIZE变量,但其使用前没有定义,因此,空(2)处应该为该变量的定义。Java中Vector模板类可存储任意类型,在定义Vector模板类的对象时,需要指定Vector对象的类型。从后面的代码可以看出,Vector被用于存储整型数,所以,空(3)处应填写整型。初始化代码将0到5共6个整数存储到theVector对象中,所以,空(4)处将循环变量的值存入theVector中。程序运行时将首先输出0至5,其次会删除第3个元素,再次输出时将不再包含整数3。

更新时间:2021-11-26 22:11

你可能感兴趣的试题

单选题

( )is that it provides guidance and direction on how quality will be managed and verified throughout the project.

  • A.Plan Quality Management
  • B.Manage Quality
  • C.Control Quality
  • D.Project Charter
查看答案
单选题

( )the process of determining,documenting,and managing stakeholder needs and requirements to meet Project objectives.

  • A.Plan Scope Management
  • B.Collection Requirements
  • C.Validate Scope
  • D.Control Scope
查看答案
单选题

The information security management system preserves the confidentiality,integrity and availability of information by applying a( ).

  • A.technology management process
  • B.resource management process
  • C.quality management process
  • D.risk management process
查看答案
单选题

( )is a decentralized database,ensure that the data will not be tampered with and forged.

  • A.Artificial intelligence
  • B.Blockchain
  • C.Sensing technology
  • D.Big datA
查看答案
单选题

( )puts computer resources on the web,and must meet the requirements of super capacity,super concurrency,super speed and super security.

  • A.Cloud computing
  • B.Big datA
  • C.Blockchain
  • D.Internet of things
查看答案
单选题

分配甲、乙、丙、丁四个人去完成五项任务。每人完成各项任务时间如表所示。由于任务多于人数,故规定其中有一个人可兼完成两项任务,其余三人每人完成一项。为了花费时间最少,( )应该完成两项任务。

高级信息系统项目管理师,历年真题,2021年下半年《信息系统项目管理师》真题

  • A.甲
  • B.乙
  • C.丙
  • D.丁
查看答案
单选题

已知某公司生产AB两种产品,其中生产1件A产品需要1个单位的甲资源,3个单位的丙资源;生产1件B产品需要2个单位的乙资源和2个单位的丙资源。已知现有甲乙丙三种资源4个单位、12个单位和18个单位。通过市场预测,可知A产品的单位市场利润为2元,B产品的单位市场利润为5元。该公司获得最大的市场利润应生产A产品(68)件,此时(69)资源仍有剩余。

  • A.甲
  • B.乙
  • C.丙
  • D.甲及丙
查看答案
单选题

已知某公司生产AB两种产品,其中生产1件A产品需要1个单位的甲资源,3个单位的丙资源;生产1件B产品需要2个单位的乙资源和2个单位的丙资源。已知现有甲乙丙三种资源4个单位、12个单位和18个单位。通过市场预测,可知A产品的单位市场利润为2元,B产品的单位市场利润为5元。该公司获得最大的市场利润应生产A产品(68)件,此时(69)资源仍有剩余。

  • A.0
  • B.2
  • C.4
  • D.6
查看答案
单选题

某项目2016年投资额12万元,2018年开始取得项目的净收益(产品一原料辅料及公用工程)6万元/年,2018-2021年每年还会产生其他成本(包括人员工资、管理成本、制造成本等)1.1万元/年;増值税0.35万元/年、营业税金及附加0.05万元/年。则该项目的静态投资回收期为(66)年,截止到2021年底该项目的投资收益率是(67)。

  • A.0.25
  • B.0.33
  • C.0.35
  • D.0.6
查看答案
单选题

安全审计的手段主要包括( )。

  • A.①②③
  • B.②③④
  • C.①②④
  • D.①③④
查看答案