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

题目内容 (请给出正确答案)

下面的程序是求字符串的长度及每一个位置上的字符。请在每条横线处填写一条语句,使程序的功能完整。

注意;请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。

public class CharAtOp{

public static void main(String args[ ]){

String str="abcdef";

int size=

System.out.println("字符串str的长度为: "+size);

for(int m=0;___________________m++)

{

_______________________

System.out.println("str中的第"+m+"个字符是: "+c);

}

}

}


参考答案

更多 “ 下面的程序是求字符串的长度及每一个位置上的字符。请在每条横线处填写一条语句,使程序的功能完整。注意;请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class CharAtOp{public static void main(String args[ ]){String str="abcdef";int size=System.out.println("字符串str的长度为: "+size);for(int m=0;___________________m++){_______________________System.out.println("str中的第"+m+"个字符是: "+c);}}} ” 相关考题
考题 最大真约数是指一个数的(除它本身之外)最大约数。下面的程序是求一个数的最大真约数,请在程序的每条横线处填写一个语句,使程序的功能完整(例如:100的最大真约数是50)。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class MaxDiv{public static void main(String args[ ]){int a=100;______________while(i0){if(____________________)_____________________i--;}System. out. print in (a+"的最大真约数为: "+i );}}

考题 选择排序的基本思想是从序列中选出最小值,将它放在前面第0位置:然后在剩下的数中选择最小值,将它放在前面第 1位置,依此类推。请在程序的每条横线处填写一条语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class SelectSort{public static void main(String args [ ]){int i,j;int a[ ]={30,1,-9,70,25}int size=a.length;for(i=0;_____________________i++)for (j=i+1;_______________j++)if(a[i]>a[j]){int temp=a[i];______________a[j]=temp;}for(i=0;i<size;i++)System.out.println(a[i]+ "" );}}

考题 接口是抽象方法和常量的集合,是一种特殊的抽象类。下面的程序是对接口的操作,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________MyInterface{public static int NUM=100;public abstract void print();}public class ClassName___________MyInterface{public void print(){System.out.println(NUM);}public static void main(String args[]){__________________________obj .print();}}

考题 下面的程序是10000以内的“相亲数”。所谓相亲数是指这样的一对数:甲数的约数之和等于乙数,而乙数的约数等于甲数,(例如220和284是一对相亲数)请在程序的每条横线处填写一条语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class QinShu{public static void main(String args[ ]){for(int n=1;n<9999;n++){int s=divsum(n);if( )System.out.println(n+","+s);}}public static int divsum(int n){//该方法的功能是求一个数的所有约数int s=0;for(int i=1;____________________i++)if(____________________)s+=i;return s;}}

考题 下面的程序是用do-while语句计算10的阶乘。请在程序的每条横线处填写1个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容;仅在横线处填入适当的语句。源程序文件代码清单如下:public class DoWhileLoop{public static void main(______){int n=10;long result=1;do{_____;}_____;System.out.println("10的阶乘为:"+result);}}

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

考题 下面程序执行后,输出结果为:true请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class TestStringCompare{{public static void main(String ____________________ args){char charl[]={'t','e','s','t'};char char2[]={'t','e','s','t','1'};String str1=new String(___________________);String str2=new String(char2,0,4);System.out.println(__________________________);}}

考题 下面的程序的功能是将数组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);}}

考题 创建线程对象,要传递代码与数据,而传递代码与数据有两种方法,一是通过继承Thread类,二是向Thread类传递一个Runnable对象。请在下面程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class TestThread{public static void main(String args[ ]){MyThread t=new MyThread();_______________________}}class MyThread_____________Thread{_____________________{for(int i=0;i10;i++){System.out.println(" " +i);}}}

考题 下面的程序是求菲波那契(Fibonacci)数列的前10项。已知该数列的前两项都为1,即F(1)=1,F(2)=1;而后面各项满足: F(n)=F(n-1)+F(n-2)。请在程序的每条横线处填写一条语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class Fibonacci{public static void main(String args[]){System.out.printtn("Fibonacci is"+" "+"_______________________);}static long fib(int n){if(______________)return 1;elsereturn _________________}}

考题 下面的程序的功能是简单的进行键盘输入测试,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。____________________public class TestKeyBoardInPut{public static void main(String[] args){String yourname=JOptionPane. ____________________ ("What is your name?");System.out.println("Hello"+yourname);____________________.exit(0);}}

考题 下面的程序的功能是求1~100的奇数的和及该和的平均值。请在程序的每条横线处填写一个语句,程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class SumAndAve{public static void main(String args[ ]){int count=0,sum=0,ave=0;for(int i=1;i<=100;____________________)if(_____________________)continue;else{___________________sum=sum+i;}ave=sum/count;System.out.println("sum="+sum);System.out.println("ave="+ave);}}

考题 下面是一个Applet小程序,其功能为:以坐标(10,20)为起点,画一条长为80个像素点的绿色直线,请在横线处填写一条语句,使程序的完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________________import java.awt.*;public class test_drawline extends Applet{public void paint(_______________){g.setColor(Color.green);_____________________}}

考题 下面的程序是打印输出100~300之间的不能被3整除的数。请在每条横线处填写一条语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填人适当的语句。public class printNo3and5{void print(){int n ;for(n=100 ;n=300 ;n++){if(n%3==0)__________System.out.println(n);}}public static__________main(String args[]){printNo3and5 bj=new printN03and5();__________}}

考题 请在下列程序中的横线处填写正确的语句。include using namespace std; class Base{ pu 请在下列程序中的横线处填写正确的语句。include<iostream>using namespace std;class Base{public:void fun(){cout<<“Basefun”<<endl;});class Derivde:public Base{public:void fun(){//调用基类的函数fun()cout<<“Derived fun”<<endl;}};

考题 下面程序的功能是从键盘读取一行文本并将该文本存储到文件中。当用户运行该程序时,需要输入一行文本并按下回车键。然后在DOS系统提示符处输入type file.txt并按下Enter键,这时屏幕会显示type file.txt的内容。通过这个命令可以验证该程序的功能。请在每条横线处填写一条语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序文件代码清单如下:import java.io.*;public class DoFile{public static void main(String args[]){byte buffername[]=______[80];try{System.out.println("\nEnter a line to be saved to disk:");int bytesbleck= ______;FileOutputStream f=new FileOutputStream("file.txt");______;}catch(Exception e){e.printStackTrace();}}}

考题 下述程序用来输出两个字符串前7个字符中对应相等的字符及其位置号,则程序横线处应该填写的是( )。A.B.C.D.A.AB.BC.CD.D

考题 下面的程序是求9999以内的“完全数”。所谓完全数是指这样的自然数:它的各个约数(不包括该数自身)之和等于该数自身。如28=1+2+4+7+14就是一个完全数。请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class QuanShu{public static void main(String args[]){for(int n=l;n<9999;n++)if(______________)System.out.println(n);}public static iht divsum(int n){//该方法功能是求一个数的所有约数int s=0;for(int i=l;i<n;i++)if(_________________)__________________return s;}}

考题 下面是打印输出所有和为10000的连续整数(如:1998,1999,2000,2001,2002)的程序,请在每条横线处填写适当语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class Sum10000{public static void main(String args[ ]){int i;int j;int k;int sum;for(i=1;i<=10000;______________){sum=0;j=i;__________________;while(sum<10000){______________if(sum==10000) {for(k=i;k<=j;k++)System.out.println(k+ "");System.out.println("********");}}}}

考题 下面的程序的功能是求1~100的奇数的和及该和的平均值。请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class SumAndAve{public static void main(String args[]){int count = 0, sum = 0, ave= 0;for (int i = 1; i<= 100; ______)if(______)continue;else{______sum=sum+i;}ave= sum/count;System.out.println( "sum="+sum);System.out.println( "ave="+ave);}}

考题 下面是关于字符界面基本输入输出的程序,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________________public class SimpleCharInOut{public static void main(String args[]){char c=" ";System.out.println("Enter a character please: ");try{____________________//接受用户键盘输入的字符并保存在变量c中}catch(________________________e){}System.out.println("You've entered character "+c);}}

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

考题 下列给定程序中,函数fun的功能是:求ss所指字符串数组中长度最短的字符串所在的行下标,作为函数值返回,并把其串长放在形参n所指的变量中。ss所指字符串数组中共有M个字符串,且串长小于N。请在程序的下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。

考题 下列程序的功能是在监控台上每隔一秒钟显示一个字符串"Hello!",能够填写在程序中下划线位置,使程序完整并能正确运行的语句是publicclassTestimplementsRunnable{publicstaticvoidmain(Stringargs[]){Testt=newTest();Threadtt=newThread(t);tt.start();}publicvoidrun(){for(;;){try{}catchL______e){}System.out.println("Hello");}}}A.B.C.D.

考题 下列程序的功能是在监控台上每隔-秒钟显示-个字符串”Hello!¨,能够填写在程序中下画线位置,使程序完整并能正确运行的语句是( )。A.sleep(1000)B.t. sleep(1000) InterruptedExceptionInterruptedExceptionC.Thread. sleep(1000)D.Thread. sleep(1000) RuntimeExceptionlnterruptedException

考题 请在下列程序的横线处填写正确的语句。include using namespace std; class Base{ publ 请在下列程序的横线处填写正确的语句。include<iostream>using namespace std;class Base{public:void fun(){cout<<"Base fun"<<endl;}};class Derivde:public Base{public:void fun(){______∥ 调用基类的函数