阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。【说明】java.util库中提供了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至5for (int cEachItem = 0; cEachItem < ARRAY_SIZE; cEachItem++)theVector.add((4));showVector(theVector); // 依次输出theVector中的元素theVector.removeElementAt(3);showVector(theVector);}public static void showVector(Vector<Integer> theVectorif (theVector.isEmpty()) {System.out.println("theVectcr is empty.");return;}for (int loop = 0; loop < theVector.size(); loop++)System.out.print(theVector.get(loop));System.out.print(", ");}System.out.println();}}该程序运行后的输出结果为:0,1,2,3,4,5(5)

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

【说明】

java.util库中提供了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("theVectcr is empty.");

return;

}

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

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

System.out.print(", ");

}

System.out.println();

}

}

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

0,1,2,3,4,5

(5)


相关考题:

阅读以下说明和Java代码,填补空缺。[说明]java.util库中提供了Vector模板类,可作为动态数组使用,并可容纳任意数据类型。该类的部分方法说明如下所示:方法名 含义add(k) 向vector对象的尾部添加一个元素kremoveElementAt(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至5for(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___________

阅读以下说明和C++代码,将应填入(n)处的字句写在对应栏内。【说明】C++标准模板库中提供了vector模板类,可作为动态数组使用,并可容纳任意数据类型,其所属的命名空间为std。vector模板类的部分方法说明如下表所示:【C++代码】include <iostream>include <vector>using namespace (1);typedef vector< (2) > INTVECTOR;const int ARRAY_SIZE = 6;void ShowVector (INTVECTOR theVector);int main() {INTVECTOR theVector;// 初始化 theVector, 将theVector的元素依次设置为0至5for (int cEachItem = 0; cEachItem < ARRAY_SIZE; cEachItem++}theVector.push_back((3));ShowVector(theVector); // 依次输出theVector中的元素theVector.erase (theVector.begin () + 3};ShowVector(theVector);}void ShowVector (INTVECTOR theVector) {if (theVector.empty ()) {cout << "theVector is empty." << endl; return;}INTVECTOR::iterator (4);for (theIterator=theVector.begin(); theIterator !=theVector.end(); theIterator++) {cout << *theIterator;if (theIterator != theVector.end()-1) cout << ", ";}cout << end1;}该程序运行后的输出结果为:0,1,2,3,4,5(5)

阅读以下说明和JAVA 2代码,将应填入(n)处的字句写在对应栏内。[说明]以下程序为类类型的变量应用实例,通过异常处理检验了类CCircle的变量的合法性,即参数半径应为非负值。仔细阅读代码和相关注释,将程序补充完整。[JAVA代码]//定义自己的异常类class CCircleException extends Exception{}// 定义类 CCircleclass CCircle{private double radius;public void setRadius ( double r ) (1){if ( r<0 ) {(2)}else(3)}Public void show ( ) {System. out. println ( "area="+3.14*radius*radius );}}public class ciusample{public static void main ( String args[] ){CCircle cir=new CCircle( );(4) {cir. setRadius ( -2.0 )}(5){System. out. println ( e+" throwed" ) ;}cir. show( ) ;}}

试题三(共 15 分)阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。

试题六(共 15 分)阅读以下说明和 C++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。[说明]C++标准模板库中提供了 vector 模板类,可作为动态数组使用,并可容纳任意数据类型,其所属的命名空间为 std。vector模板类的部分方法说明如下表所示:[C++代码]include iostreaminclude vectorusing namespace (1) ;typedef vector (2) INTVECTOR;const int ARRAY_SIZE = 6;void ShowVector(INTVECTOR theVector);int main(){INTVECTOR theVector;// 初始化 theVector,将 theVector的元素依次设置为 0 至 5for (int cEachItem = 0; cEachItem ARRAY_SIZE; cEachItem++)theVector.push_back( (3) );ShowVector(theVector); // 依次输出 theVector中的元素theVector.erase(theVector.begin() + 3);ShowVector(theVector);}void ShowVector(INTVECTOR theVector) {if (theVector.empty()) {cout "theVector is empty." endl; return;}INTVECTOR::iterator (4) ;for (theIterator = theVector.begin(); theIterator != theVector.end(); theIterator++){cout *theIterator;if (theIterator != theVector.end()-1) cout ", ";}cout endl;}该程序运行后的输出结果为:0, 1, 2, 3, 4, 5(5)

试题七(共 15 分)阅读以下说明和 Java 代码,将应填入 (n) 处的字句写在答题纸的对应栏内。[说明]java.util 库中提供了 Vector 模板类,可作为动态数组使用,并可容纳任意数据类型。该类的部分方法说明如下表所示:[Java 代码]import (1) ;public class JavaMain {static private final int (2) = 6;public static void main(String[] args){VectorInteger theVector = new Vector (3) ();// 初始化 theVector,将 theVector的元素设置为 0 至 5for (int cEachItem = 0; cEachItem ARRAY_SIZE; cEachItem++)theVector.add( (4) );showVector(theVector); // 依次输出 theVector中的元素theVector.removeElementAt(3);showVector(theVector);}public static void showVector(VectorInteger 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();}}该程序运行后的输出结果为:0, 1, 2, 3, 4, 5(5)

阅读下列说明和C++-代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图5-1所示的类图。【C++代码】 #include using namespace std; class invoice{ public: (1){ cout

阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】 某文件管理系统中定义了类OfficeDoc和DocExplorer,当类OfficeDoc发生变化时,类DocExplorer的所有对象都要更新其自身的状态,现采用观察者(Observer)设计模式来实现该需求,所设计的类图如图6-1所示。

阅读下列说明和?C++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】阅读下列说明和?Java代码,将应填入?(n)?处的字句写在答题纸的对应栏内。【说明】某快餐厅主要制作并出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种类可能不同,但其制作过程相同。前台服务员?(Waiter)?调度厨师制作套餐。现采用生成器?(Builder)?模式实现制作过程,得到如图?6-1?所示的类图。