网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是(  )。public class FindKeyWords{ public static void main(String[]args) {  String text = An array is a data structur that stores a collection of   +values of the same type. You access each individual value   +through an integer index. For example,if a is an array   +of inergers,then a[i] is the ith integer in the array.;  int arrayCount=0;  int index=-1;  String arrayStr=array;  index=text.indexOf(arrayCount);  while(index ______ 0)  {   ++arrayCount;   index+=arrayStr.length();   index=text.indexOf(arrayStr,index);   System.out.println(the text contains+arrayCount+arrays);  } }}
A

<

B

=

C

<=

D

>=


参考答案

参考解析
解析:
indexOf()方法有以下四种形式:
①public int indexOf(int ch):返回指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回-1。
②public int indexOf(int ch, int fromIndex):返回从 fromIndex 位置开始查找指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回-1。
③int indexOf(String str):返回指定字符串在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回 -1。
④int indexOf(String str, int fromIndex):返回从fromIndex位置开始查找指定字符串在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回-1。
在while循环中,每次indexOf()方法都从上次报告索引再加上该指定字符长度(即跳过上次找到的字符)的位置开始查找。若还能找到,则返回一个大于等于0的整数,为匹配的字符的索引;否则,返回-1。所以程序中只有当indexOf()方法返回的index>=0时,才继续执行while循环。
更多 “单选题下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是(  )。public class FindKeyWords{ public static void main(String[]args) {  String text = An array is a data structur that stores a collection of   +values of the same type. You access each individual value   +through an integer index. For example,if a is an array   +of inergers,then a[i] is the ith integer in the array.;  int arrayCount=0;  int index=-1;  String arrayStr=array;  index=text.indexOf(arrayCount);  while(index ______ 0)  {   ++arrayCount;   index+=arrayStr.length();   index=text.indexOf(arrayStr,index);   System.out.println(the text contains+arrayCount+arrays);  } }}A B =C =D =” 相关考题
考题 有如下程序:#includeusing namespace std;class ONE{public:virtual void f(){cout"l";}};class TWO:public ONE{public:TWO(){cout"2";}};class THREE:public TWO{public:virtual void f(){TWO::f(); cout"3";}};int main(){ONE aa, *p;TWO bb;THREE cc;p = cc;p-f();return 0;}执行上面程序的输出是 【 11 】 。

考题 有如下程序: include using namespaee std; class ONE{ public: virtual void f 有如下程序:include <iostream>using namespaee std;class ONE{public:virtual void f( ){cout<<"1";}};class TWO:public ONE{public:TWO( )1 cout<<"2";}{;class THREE:public TWO{public:virtual void f( )}TWO::f( );cout<<"3";}};int main( ){ONE aa,*P;TWO bb;THREE cc;P=cc;p->f( );return 0;}程序的输出结果是______。

考题 阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】StringEditor类的功能是:已知一个字符串,返回将字符串中的非字母字符都删除后的字符串。public (1) {public static String removeNonLetters( (2) ){StringBuffer aBuffer=(3);char aCharacter;for(int i=0; i<original.length();i++){aCharacter=(4);if(Character.isLetter(aCharacter))aBuffer.append( (5) );}return new String(aBuffer);}}public class StringEditorTester{public static void main(String args[]){String riginal="Hi!, My Name is Mark, 234I think you are my classmate?!!";System.out.println(StringEditor.removeNonLetters(original));}}

考题 有如下程序: include using namespace std; class A { public: virtual void f(){cout 有如下程序:include<iostream>using namespace std;class A{public:virtual void f(){cout<<"1";}};class B:public A{public:B (){cout<<"2";}};class C:public B{public:virtual void f(){B::f();cout<<"3";}};int main(){A aa,*p;B bb;C cc;p=cc;p->f();return 0;}执行上面程序的输出是______。

考题 ( 30 )下列程序的功能是统计字符串中 “ array ” 的个数,在程序的空白处应填入的正确选项是public class FindKey Word s{public static void main(sring[] args){sting text=“ An array is a data structur that stores a collection of ”+ “ values of the same type . You access each individual value ”+ “ through an integer index . For example,if a is an array ”+ “ of inergers, then a[i] is the ith integer in the array. ” ;Int arrayCount =0;Int idex = -1;Sting arrarStr = ” array ” ;Index = text.indexof(arrayStr);While(index______ 0) {++arrayCount;Index += arrayStr.length();Index = text.indexof(arrayStr,index);}System.out.println( “ the text contains ” + arrayCount + “ arrays ” );}}A) B) =C) =D) =

考题 以下程序的功能是统计字符串A中出现字符串B的次数,然后输出,请在填空[9]处填入适当的程序完成功能。

考题 下列程序的功能是为变量赋值,程序运行后,输出i=51。请改动main方法中的错误,使程序能够正确编译、运行并输出正确的结果。注意:不改动程序结构。class A{private int a;public void setA (int x){a=x;}public int getA(){return a;}}public class MethodTest{public static void main(String args[]){A a=A();a.getA(51);int i=a.getA();System.out.println ("i="+i);}}

考题 下面的程序的功能是将数组array下标为奇数的元素相乘(数组的位置是从0开始的),并将乘积存放到变量total中。请在程序的每条横线处填入适当的语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class JiShuJi{public static void main(String args[ ]){int array[ ]={1,2,3,5,7,9};long total= ________________________;for(int i=1;i<=__________________ i++){____________________i++;}System.out.println(total);}}

考题 下面程序的功能是将数组array下标为奇数的元素相乘(数组的位置是从0开始的),并将乘积存放到变量 total中。请在程序的每条横线处填写—个位运算符,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序代码文件清单如下:public class JiShuJi{public static void main(String args[]){int array[ ]={1,2,3,5,7,9};long total=for(int i=1;i<=______;i++){______;i++;}System.out.println(total);}}

考题 如下程序的输出是includeusing namespace std;class Base{public:Base( ){cout 如下程序的输出是 #include<iostream> using namespace std; class Base{ public: Base( ){cout<<"BB";f( );} void f( ){cout<<"Bf";} }; class Derived:public Base{ public: Derived( ){eout<<"DD";} void f( ){cout<<"Df";} }; int main( ){Derived d;return 0;}A.BBBff)DB.BBDfDDDfC.DDD.DDBBBf

考题 下列程序的运行结果是______。include class Base { public: void f(int x){cout 下列程序的运行结果是______。include<iostream.h>class Base{public:void f(int x){cout<<“Base:”<<x<<endl;});class Derived:public Base{public:void f(char*str){cout<<“Derived:”<<str<<endl;}};void main(void){Base*pd=ne

考题 在下列程序画线处填入的正确语句是()。includeusing namespace std;classBase{public: 在下列程序画线处填入的正确语句是( )。 #include <iostream> using namespace std; class Base { public: void fun() { cout<<"Base::fun",<<end1; } }; class Derived:public Base { void fun() { ______________ //显式调A.fun();B.Base.fun();C.Base::fun();D.Base->fun();

考题 阅读下面程序 public class Test2______ { public static void main(String[] args){ Thread t=new Test2(); t. start(); } public void run(){ System. out. priatln("How are you. "); } } 在程序下画线处填入的正确的选项是A.implements ThreadB.extends RunnableC.implements RunnableD.extends Thread

考题 在下列程序的空白处,应填入的正确选项是( )。A.start( )B.close( )C.read( )D.write( )

考题 下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。A.B.=C.=D.=

考题 下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。 public class FindKeyWords( public static void main(sring[]args){ sting text= "An array is a data structur that stores a eollection of" +"values of the same type.You access each individu- al value" +"through an integer index.For example.if a is an array" +"of inergers,then all]is the ith integer in the ar- ray."; Int arrayCount=0; Int idex=-l; Sting arrarStr="array": Index=text.indexof(arrayStr); While(index 0){ ++arrayCount: Index+=arrayStr.1ength; Index=text.indexof(arrayStr,index); } System.OUt.println ("the text contains"+arrayCount+"arrays"); } }A.B.=C.=D.=

考题 有下列程序:includeusing namespace std;class ONE{ public:virtual void f(){COUt 有下列程序:include<iostream>using namespace std;class ONE{public:virtual void f(){COUt<<"1";}};c1assTWO:public ONE{public:TWO(){cout<<"2";}};class THREE:public TWO{pub

考题 下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。 publicclassFindKeyWords{ publicstaticvoidmain(sring[]args){ stingtext= “Anarrayisadatastructurthatstoresacollectionof” +“valuesofthesametype.YOUaccesseachindividualvalue'’ +“throughanintegerindex.Forexample,ifaiSanarray” +“of inergers,thena[i]iSthe ith integer in thearray.”; In tarrayCount=0; Intidex=-1; Sting arrarStr=“array”; IndeX=text.indexof(arrayStr); While(index______0){ ++arrayCount; Index+=arrayStr.length(); IndeX=text.indexof(arrayStr,indeX); } SyStem.out.phntln (“thetextcontains”+arrayCount+“arrays”); } }A.<B.=C.<=D.>=

考题 下列给定程序中,函数fun的功能是:从形参SS所指字符串数组中,删除所有串长超过k的字符串,函数 返回剩余字符串的个数。ss所指字符串数组中共有N个字符串,且串长小于M。请在程序的下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。注意:部分源程序在文件BLANKl.C中。不得增行或删行.也不得更改程序的结构!

考题 在下列程序的空白处,应填入的正确选项是( )。A.WriterObjectB.WriterC.BufferedWriterD.writerObject

考题 下列哪个选项的java源文件程序段是不正确的? ( )A.package testpackage; public class Test{ }B.import java.io.*; package testpackage; public class Test{ }C.import java.i.*; class Person{} public class Test{ }D.import java.io.*; import java.awt.*; public class Test { }

考题 有下列程序: include using namespace std; class Base { public: Base(){cout 有下列程序: #include<iosteram.h> using namespace std; class Base { public: Base(){cout<<"BB"; f(); } void f(){cout<<"Bf";} }; class Derived:public Base { public: Derived(){cout<<"DA.BBBfDDB.BBDfDDDfC.DDD.DDBBBf

考题 阅读下面程序 public class Test2 ______ { public static void main(String[] args) { Thread t=new Test2(); t.start(); } public void run() { System.out.println("How are you."); } } 程序中下画线处应填入的正确选项是A.implements ThreadB.extends RunnableC.implements RunnableD.extends Thread

考题 下面程序的功能是()。include include using namespace std;int main (){ in 下面程序的功能是( )。 #include <iostream> #include <string> using namespace std; int main () { int i=1, n=0; char s[80],*p; p=s; strcpy(p,"It is a book.."); for (; *p !=' \0' ;p++) { if(*p=='') i=0; else if (i==0) { n++; i=1; } } cout<<"n=" <<n<<end1; return 0; }A.统计字符串中的单词个数B.统计字符串中的空格个数C.统计字符串中的字母个数D.统计字符串中的全部字符个数

考题 下列程序片段中,能通过编译的是( )。 A.public abstract class Animal{ public void speak;}S 下列程序片段中,能通过编译的是( )。A.public abstract class Animal{ public void speak;}B.public abstract class Animal{ public void speak{);}C.public class Animal{ pubilc abstract void speak;}D.public abstract class Animal{ pubile abstract void speak{};}

考题 下列的程序的功能是求2~100之间的素数,程序中划线部分应填入的选项是 public class Testnn { public static void main(String args[]) { Labell: for(int i=2;i100;i++) { for(int j=2;j<i;j++) { if(i%j==______)continue Labell; } System.out.println(i); } } }A.0B.1C.iD.j

考题 ( 11 )下列程序的功能是统计命令行参数的个数,请在下划线处填上适当的代码。public class Length{public static void main(String args[]){System.out.println( " number of String args: " +args. 【 11 】 );}}

考题 程序中有一空白处,需要填入一条语句使程序完成其功能。下列选项中错误的语句是()。A、flag=FalseB、flag=NotflagC、flag=TrueD、ExitDo