网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
publicstaticvoidtest(Stringstr){intcheck=4;if(check=str.length()){System.out.print(str.charAt(check-=1)+,);}else{System.out.print(str.charAt(0)+,);}}andtheinvocation:test(”four”);test(”tee”);test(”to”);Whatistheresult?()
A.r,t,t,
B.r,e,o,
C.Compilationfails.
D.Anexceptionisthrownatruntime.
参考答案
更多 “ publicstaticvoidtest(Stringstr){intcheck=4;if(check=str.length()){System.out.print(str.charAt(check-=1)+,);}else{System.out.print(str.charAt(0)+,);}}andtheinvocation:test(”four”);test(”tee”);test(”to”);Whatistheresult?()A.r,t,t,B.r,e,o,C.Compilationfails.D.Anexceptionisthrownatruntime. ” 相关考题
考题
已知String str=new String ("Luck");,则下列关于str的操作中不合法的是( )。A.String s=str. toUpperCase()B.int i=Str. length;C.char s=str. charAt(2);D.String s="Good" +str;
考题
public static void main(String[]args){String str=null;if(str==null){System.out.println(null);}else(str.length()==0){System.out.println(zero);}else{System.out.println(some);}}What is the result?()A.nullB.zeroC.someD.Compilationfails.E.Anexceptionisthrownatruntime.
考题
publicclassTestString1{publicstaticvoidmain(String[]args){Stringstr=420”;str+=42;System.out.print(str);}}Whatistheoutput?()
A.42B.420C.462D.42042E.Compilationfails.F.Anexceptionisthrownatruntime.
考题
publicstaticvoidmain(String[]args){Stringstr=null?;if(str==null){System.out.println(”null”);}else(str.length()==0){System.out.println(”zero”);}else{System.out.println(”some”);}}Whatistheresult?()
A.nullB.zeroC.someD.Compilationfails.E.Anexceptionisthrownatruntime.
考题
Giventhefollowingcodefragment:1)Stringstr=null;2)if((str!=null)(str.length()10)){3)System.out.println(morethan10);4)}5)elseif((str!=null)(str.length()5)){6)System.out.println(lessthan5);7)}8)else{System.out.println(end);}Whichlinewillcauseerror?()A.line1B.line2C.line5D.line8
考题
函数check()用来判断字符串s是否是“回文”(顺读和倒读都一样的字符串称为“回文”,如abcba)。若是回文,函数返回值为1;否则返回值为0。请完成此函数的定义。注意:部分源程序已存在考生文件夹的文件PROC7.cpp中。请勿修改主函数和其他函数中的任何内容,仅在函数check()的花括号中填写若干语句。文件PROC7.cpp的内容如下://PROC7.cppinclude<iostream>include<string>using namespace std;int check(char*s);int main(){char str[100],*p;cout<<"Input your string!";cin>>str;p=str;cout<<"The result is:"<<check(p)<<end1;}int check(char*s){// * * * * + * * *}
考题
指出下列程序运行的结果 ( ) public class Example{ String str=new String("good"); char[]ch={'a','b','c'}; public static void main(String args[]){ Example ex=new Example(); ex.change(ex.otr,ex.ch); System.out.print(ex.str+"and"); System.out.print(ex.ch); } public void change(String str,char ch[])} str="test ok"; ch[0]≈'g'; } }A.good and abcB.good and gbcC.test ok and abcD.test ok and gbc
考题
14、下面程序的运行结果是:() class test{ public static void main(String[] args) { String str = "hello zut"; System.out.print(str.charAt(2)); System.out.print(str.length()); System.out.print(str.substring(4)); } }A.e9ozutB.l9o zutC.l8 zutD.e8o zut
考题
18、请写出程序运行的结果。 string str = "abcdefg"; str + = "1234567"; int result; result= str.Length; Console.WriteLine(result);
热门标签
最新试卷