Which gets the n

题目

Which gets the name of the parent directory file “file.txt”?()

  • A、 String name= File.getParentName(“file.txt”);
  • B、 String name= (new File(“file.txt”)).getParent();
  • C、 String name = (new File(“file.txt”)).getParentName();
  • D、 String name= (new File(“file.txt”)).getParentFile();
  • E、 Directory dir=(new File (“file.txt”)).getParentDir();  String name= dir.getName();
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

If he, by accident, knocks someone, or _______ their way, he say “ Excuse me” or “I’m sorry”.

A.gets on

B.gets in

C.gets by

D.gets to


正确答案:B

第2题:

以下选项中错误的是( )

A.char *sp; gets(sp);

B.char sp[5] gets(sp);

C.char *sp="12345"; gets(sp);

D.charsp[5]="\0" gets(sp)


正确答案:A

第3题:

A fool takes in all the lumber of every sort that he comes across, so that the knowledge which might be useful to him gets crowded out, or at best jumbled up with a lot of other things, so that he has difficulty in laying his hand upon it.

_______________________________________________________________________________


正确答案:
蠢人把他碰到的每种木材(制成的家具)都拿进来。这样,可能对他有用的知识都被挤出去;最好的情况也是和其他种种事情混在一起,结果他很难抓住知识。

第4题:

有以下定义:includechara[10],*b=a;不能给数组a输入字符串的语句是A.gets(a)B.gets(a[

有以下定义: #include <stdio.h> char a[10],*b=a; 不能给数组a输入字符串的语句是

A.gets(a)

B.gets(a[0])

C.gets(&a[0]);

D.gets(b);


正确答案:B
解析:本题考核的知识点是函数gets()的应用。函数gets()的调用形式为gets(str_adr);str_adr是存放字符串的起始地址。可以是字符数组名、字符指针或字符数组元素的地址。gets函数用来从终端键盘读入字符串(包括空格符),直到读入一个换行符为止。换行符读入后,不作为字符串的内容。本题中定义一个长度为10的字符数组,和一个指针变量b,并且通过赋值让它指向数组a;选项A。选项B。选项C和选项D中只有选项B中gets函数的参数a[0]不能表示数组a的首地址,故选项B不正确。所以,4个选项中选项B符合题意。

第5题:

有以下定义:include char a[10], *b=a; 下面不能给数组a输入字符串的语句是()。A.gets(

有以下定义: #include <stdio.h> char a[10], *b=a; 下面不能给数组a输入字符串的语句是( )。

A.gets(a)

B.gets(a[0]);

C.gets(&a[0]);

D.gets(b);


正确答案:B
解析:函数gets(字符数组)的功能是从终端输入一个字符串到字符数组,并且得到一个函数值,该函数值是字符数组的起始地址。函数的参数应该是一个指针,所以选项B)错误。

第6题:

Evaluate the following function code:Which statement is true regarding the above function? ()

A. The cached result becomes invalid when any structural change is done to the EMPLOYEES table.

B. If the function execution results in an unhandled exception, the exception result is also stored in the cache.

C. Each time the function is invoked in a different session, the current result in the result cache gets overwritten.

D. If the function is invoked with a different parameter value, the existing result in the result cache gets overwritten by the latest value.


参考答案:A

第7题:

设有下列程序: include include main() { int i; char si 10],ti 10]; gets(

设有下列程序:

include<stdio.h>

include<string.h>

main()

{ int i;

char si 10],ti 10];

gets(t);

for(i=0;i<2;i++)

{ gets(s);

if(strcmp(t,s)<0)strcpy(t,s);

}

printf("%s\n",t);

}

程序运行后,从键盘上输入(<CR>代表回车符):CDEF<CR>BADEF<CR>QTHRG<CR>,则程序的输出结果是______。


正确答案:QTHRG
QTHRG 解析:strcmp(t,s)函数用来比较t和s所指字符串的大小,若t>s,则函数值大于0;若t=s,则函数值等于0;若ts,则函数值小于0。strcpy(t,s)函数的功能是把字符数组,所指字符串的内容复制到字符数组t所指的存储空间中。
本题中,t[10]="CDEF".第一次循环,s[10]="BADEF",if语句的控制条件strcmp(t,s)0不成立,接着执行第二次循环,s="QTHRG”, if语句的控制条件strcmp(t,s)0成立,执行下列的语句,将字符数组s所指字符串的内容复制到字符数组t所指的存储空间中,然后输出字符数组t。

第8题:

16.

A. gets up

B. gets on

C. gets into

D. gets off


正确答案:C
16.C【解析】下文讲老人乘格林先生的车到家后才告诉他去旅馆的路,选C,表示老人上了格林先生的汽车。注意“上小汽车”英语是get into the car,而上公共汽车或火车则是get on the bus或get on the train。

第9题:

以下程序includemain(){char a1[80],a2[80],*s1=a1,*s2=a2; gets(s1);gets(s2) if(!s

以下程序 #include<string.h> main() { char a1[80],a2[80],*s1=a1,*s2=a2; gets(s1);gets(s2) if(!strcmp(s1,s2))printf("*"); else printf("#"); printf("%d\n",strlen(strcat(s1,s2))); } 如果从键盘上输入: book<回车> book<空格><回车> 则输出结果是( )

A.*8

B.#9

C.#6

D.*9


正确答案:B

第10题:

有以下定义 include char a[10],*b=a; 不能给a数组输入字符串的语句是A.gets(A)B.gets

有以下定义

#include <stdio.h>

char a[10],*b=a;

不能给a数组输入字符串的语句是

A.gets(A)

B.gets(a[0]);

C.gets(&a[0]);

D.gets(B) ;


正确答案:B
解析:函数gets()的调用形式为gets(str_adr);str_adr是存放字符串的起始地址。可以是字符数组名、字符指针或字符数组元素的地址。gets函数用来从终端键盘读入字符串(包括空格符),直到读入一个换行符为止。换行符读入后,不作为字符串的内容。本题中定义一个长度为10的字符数组,和一个指针变量b,并且通过赋值让它指向数组a。gets函数的参数a[0]不能表示数组a的首地址。

更多相关问题