9、下列代码的执行结果是______。 int length ="Hello".length(); System.out.println(length);A.5B.2C.10D.6
9、下列代码的执行结果是______。 int length ="Hello".length(); System.out.println(length);
A.5
B.2
C.10
D.6
参考答案和解析
A 字符串”Hell0”的长度是5,java在计算字符串长度时只计算实际字符串长度。
相关考题:
下列代码的执行结果是______。Int length="Hello", length();System.out.println(lenght);A) 5B) 2C) 10D) 6A.B.C.D.
int型public成员变量MAX_LENGTH,该值保持为常数100,则定义这个变量的语句是 ( )。A.public int MAX_LENGTH=100B.fmal int MAX_LENGTH=100C.pubic const int MAX_LENGTH=100D.public final int MAX_LENGTH=100
Whichcodefragmentswillsucceedinprintingthelastargumentgivenonthecommandlinetothestandardoutput,andexitgracefullywithnooutputifnoargumentsaregiven?()CODEFRAGMENTa:publicstaticvoidmain(Stringargs[]){if(args.length!=0)System.out.println(args[args.length-1]);}CODEFRAGMENTb:publicstaticvoidmain(Stringargs[]){try{System.out.println(args[args.length]);}catch(ArrayIndexOutOfBoundsExceptione){}}CODEFRAGMENTc:publicstaticvoidmain(Stringargs[]){intix=args.length;Stringlast=args[ix];if(ix!=0)System.out.println(last);}CODEFRAGMENTd:publicstaticvoidmain(Stringargs[]){intix=args.length-1;if(ix0)System.out.println(args[ix]);}CODEFRAGMENTe:publicstaticvoidmain(Stringargs[]){try{System.out.println(args[args.length-1]);}catch(NullPointerExceptione){}}
阅读下面代码 public class Arrays { public static void main(String[] args) { int[] a=new int[5]; for(int i=0;i<a.length;i=i+1)a[i]=10+i; for(int i=0;i<a.length;i=i+1)System.out.println(a[i]); String[] s={"Frank","Bob","Jim"}; for(int i=0;i<s.length;i=i+1)System.out.println(s[i]); s[2]="Mike"; System.out.println(s[2]); } } 代码运行正确的结果是A.10 11 12 13 14 Mike Bob Frank JimB.11 12 13 14 15 Frank Bob Mike JimC.10 11 12 13 14 Frank Bob Jim MikeD.11 12 13 14 15 Mike Jim Bob Frank
设有数组定义:int a[ ]={11,22,33,44,55,66,77,88,99};则执行下列几条语句后的输出结果是 ______。for(int i=0;i<a.length;i++)if(a[i]%3==0)System.out.println(a[i]+" ");
分析以下代码,完成填空string strTmp = "abcdefg某某某";int i= System.Text.Encoding.Default.GetBytes(strTmp).Length;int j= strTmp.Length;以上代码执行完后,i= j=
执行下面代码后:String strTemp =”abcdefg 某某某”;Int i System.Text.Encoding.Default.GetBytes(strTemp).Length;Int j = strTemp.Length;问:i=(14 ) ;j=(11 )
下列代码的执行结果是( )。 int length="Hell0".length; System.OUt.println(length); A.5S 下列代码的执行结果是( )。 int length="Hell0".length; System.OUt.println(length);A.5B.2C.10D.6
在下面程序运行includeint func(char s[]){ int length=0; while(*(s+length))leng 在下面程序运行 #include<iostream.h> int func(char s[]){ int length=0; while(*(s+length))length++; return length; } void main(){ char a[10], *ptr=a; cin>>ptr; cout<<fune(ptr)<<end1; } 如果输入字符串Hello!并回车,则输出结果为 ______。A.4B.7C.6D.5
以下( )表达式是不合法的。A.string x="hello";int y=9;x+=y;B.string x="hello";int y=9;if(x=y){}C.string x="hello";int y=9;x=x+y;D.string x=null;inty=(x!=null)(x.length()>0)?x.length():0;
设有数组定义:int a[ ] = { 11 , 22 , 33 , 44 , 55 , 66 , 77 , 88 , 99 }; 则执行以下几个语句后的输出结果是 ()、() 、() 。 for ( int i = 0 ; i a.length ; i ++ ) if ( a[i]%3==0 ) System.out.println(a[i]);
int型public成员变量MAX_LENGTH,该值保持为常数100,则定义这个变量的语句是()A、public int MAX_LENGTH=100B、final int MAX_LENGTH=100C、public const int MAX_LENGTH=100D、public final int MAX_LENGTH=100
单选题Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?() CODE FRAGMENT a: public static void main(String args[]) { if (args.length != 0) System.out.println(args[args.length-1]); } CODE FRAGMENT b: public static void main(String args[]) { try { System.out.println(args[args.length]); } catch (ArrayIndexOutOfBoundsException e) {} } CODE FRAGMENT c: public static void main(String args[]) { int ix = args.length; String last = args[ix]; if (ix != 0) System.out.println(last); } CODE FRAGMENT d: public static void main(String args[]) { int ix = args.length-1; if (ix 0) System.out.println(args[ix]); } CODE FRAGMENT e: public static void main(String args[]) { try { System.out.println(args[args.length-1]); }catch (NullPointerException e) {} }ACode fragment a.BCode fragment b.CCode fragment c.DCode fragment d.ECode fragment e.
单选题MAX_LENGTH是int型public成员变量,变量值保持为常量100,其定义是()。Afinal public int MAX_LENGTH=100;Bpublic int MAX_LENGTH=100;Cpublic final int MAX_LENGTH=100;Dfinal int MAX_LENGTH=100;
填空题设有数组定义:int a[ ] = { 11 , 22 , 33 , 44 , 55 , 66 , 77 , 88 , 99 }; 则执行以下几个语句后的输出结果是 ()、() 、() 。 for ( int i = 0 ; i a.length ; i ++ ) if ( a[i]%3==0 ) System.out.println(a[i]);
单选题A public member vairable called MAX_LENGTH which is int type, the value of the variable remains constant value 100. Use a short statement to define the variable.()A public int MAX_LENGTH=100;B final int MAX_LENGTH=100;C final public int MAX_LENGTH=100;D public final int MAX_LENGTH=100;
多选题MAX_LENGTH是int型public成员变量, 变量值保持为常量100,用简短语句定义这个变量。()Apublic int MAX_LENGTH=100;Bfinal int MAX_LENGTH=100;Cfinal public int MAX_LENGTH=100;Dpublic final int MAX_LENGTH=100.