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?()
public static void parse(String str) { try { float f= Float.parseFloat(str); } catch (NumberFormatException nfe) { f= 0; } finally { System.out.println(f); } } public static void main(String[] args) { parse(”invalid”); } What is the result?()
public class Test { public static void main(String[] args) { String str = NULL; System.out.println(str); } } What is the result?()
public class TestString 1 { public static void main(String[] args) { String str = “420”; str += 42; System.out.print(str); } } What is the output?()
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?()
以下程序运行后,文件test.txt的内容是( )。#includevoid main(){ FILE*fp;charstr[][10]={first,second};fp = fopen(test.txt,w);if(fp!=NULL)fprintf(fp,%s,str[0]);fclose(fp);fp = fopen(test.txt,w);if(fp!=NULL)fprintf(fp,%s,str[1]);fclose(fp);}
给出源字符串:String str = \i am a student
先阅读下面的程序片段:String str1=new String(\java\);String str2=new String(\java\);StringBuffer str3=new StringBuffer(\java\);对于上述定义的变量,以下表达式的值为true的是哪个?( )
执行下面的代码会引发()异常。 String str = null; String strTest = new String(str);
文本文件quiz.txt的内容为\Programming\ (不包含引号),以下程序段的运行结果是_________________ FILE *fp; char *str; if((fp=fopen(\quiz.txt\,\r\))!=NULL) str=fgets(str,7,fp); printf(\%s\,str); (6.0分)
阅读下列程序,当运行函数时,输入asd af aa z67,则输出为 include <stdio.h> include <ctype.h> include <string.h> int fun(char*str) { int i,j=0; for(i=0;str[i]!='\0';i++) if(str[i]!='')str[j++]=str[i]; str[j]='\0'; } main() { char str[81];
C中,string str = null 与 string str =””,请尽量用文字说明区别。(要点:说明详细的内存空间
指出下列程序运行的结果public class Example{ String str=newString("good"); c
函数String(n,"str")的功能是A.把数值型数据转换为字符串B.返回由n个字符组成的字符串C.从字符串
StringBuffer str=new StringBuffer(25);String s=”Hello”,若执行语句str.append(s)后,str.length()和str.capacity()的返回值为()。
以下程序段输出的结果是() public class Test{ public static void main(String[] args) { String str=”ABCDE”; str.substring(3); str.concat(“XYZ”); System.out.println(str); } }
16、下面程序的功能是从键盘输入一行字符(最长不超过80字符),用函数编程统计其中单词(以空格作为间隔符的字符串)的个数。 基本思路是:当前被检验字符不是空格,而前一被检验字符是空格,则表示有新单词出现。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。(下面答案中两个单引号''中间都有一个空格) 样例1: Input a string:How are you↙ Numbers of words = 3 样例2: Input a string: How are you↙ Numbers of words = 3 include <stdio.h> int CountWords(char str[]); int main() { char str[81]; int num; printf("Input a string:\n"); gets(str); num=CountWords(str); printf("Number of w
下面是一段javabean程序,该程序的运行结果是 () 。public class NullTest { public static void main(String[] ?args) { int M = 0; String str = null; StringBuffer sb = new StringBuffer("= "); sb.append(str); sb.ap
下面程序的功能是从键盘输入一个字符串,编程将其字符顺序颠倒后重新存放,并输出这个字符串。 程序的运行结果如下: Input a string: abcdef↙ The inversed string is: fedcba 按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 include <stdio.h> include <string.h> void Inverse(char *pStr); int main() { char str[80]; printf("Input a string:n"); gets(str); //输入字符串 Inverse(str); //将存于str数组中的字符串逆序存放 printf("The inversed string is:n"); puts(str); //输出字符串 return 0; } //函数功能: 实现字符串逆序存放 void Inverse(__________) { int len;
quiz0606 对于以下的程序 String str=new String(); str的内容"我的一切"存储在哪个地方?
下面程序段的输出结果是()。 include<string.h> void main() char str1[10]="s","t","u","d","e","n","t"; printf("%d",strlen (str1));
以下函数fun的功能是返回str所指字符串中以形参c中字符开头的后续字符串的首地址,例如:str所指字符串为:Hello!,c中的字符为e,则函数返回字符串:ello!的首地址。若str所指字符串为空串或不包含c中的字符,则函数返回NULL。请填空。 char*fun(char *str,char c) int n=0; char *p=str; if(p!=NULL)while(p[n]!=c&
下面程序的输出结果为()。 include<string.h> void main() char p1[7]="abc",p2 ="ABC",str[50]="xyz"; strcpy(str,strcat(p1,p2)); printf("%s",str);
5、以下选项中关于如下代码的说法正确的是()。 public class TestBuffered { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new FileReader("d:/wj1.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("d:/wj2.txt")); String str = br.readLine(); while(str !=null){ bw.write(str); bw.newLine(); str = br.readLine(); } br.close(); bw.close(); } }