这道题选什么.一定要告诉我为什么.Consider the following line of code( )char y[] = new char[5];After execution,which of the following are true?A.y[4] = '0' B.y[4] = '\u0000' C.y[5] = '\u0000' D.y[5] = '0'不是多选,A跟B里面 选那

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/12 05:28:29
这道题选什么.一定要告诉我为什么.Consider the following line of code( )char y[] = new char[5];After execution,which of the following are true?A.y[4] = '0' B.y[4] = '\u0000' C.y[5] = '\u0000' D.y[5] = '0'不是多选,A跟B里面 选那

这道题选什么.一定要告诉我为什么.Consider the following line of code( )char y[] = new char[5];After execution,which of the following are true?A.y[4] = '0' B.y[4] = '\u0000' C.y[5] = '\u0000' D.y[5] = '0'不是多选,A跟B里面 选那
这道题选什么.一定要告诉我为什么.
Consider the following line of code( )
char y[] = new char[5];
After execution,which of the following are true?
A.y[4] = '0' B.y[4] = '\u0000' C.y[5] = '\u0000' D.y[5] = '0'
不是多选,A跟B里面 选那一个.为什么,要具体解释.

这道题选什么.一定要告诉我为什么.Consider the following line of code( )char y[] = new char[5];After execution,which of the following are true?A.y[4] = '0' B.y[4] = '\u0000' C.y[5] = '\u0000' D.y[5] = '0'不是多选,A跟B里面 选那
正确答案是B.
因为char是原始类.
原始类在建立时都有默认值.char的默认值就是\u0000.
例子:
if(y[4] == '\u0000') {......} //这句运行的结果是true.
如果换成int,int x[] = new int[5];
这个x[]里面都是0,因为int的默认值是0.