这道题选什么.一定要告诉我为什么.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/06/29 22:43:09
![这道题选什么.一定要告诉我为什么.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里面 选那](/uploads/image/z/6854722-34-2.jpg?t=%E8%BF%99%E9%81%93%E9%A2%98%E9%80%89%E4%BB%80%E4%B9%88.%E4%B8%80%E5%AE%9A%E8%A6%81%E5%91%8A%E8%AF%89%E6%88%91%E4%B8%BA%E4%BB%80%E4%B9%88.Consider+the+following+line+of+code%28+%29char+y%5B%5D+%3D+new+char%5B5%5D%3BAfter+execution%2Cwhich+of+the+following+are+true%3FA.y%5B4%5D+%3D+%270%27+B.y%5B4%5D+%3D+%27%5Cu0000%27+C.y%5B5%5D+%3D+%27%5Cu0000%27+D.y%5B5%5D+%3D+%270%27%E4%B8%8D%E6%98%AF%E5%A4%9A%E9%80%89%2CA%E8%B7%9FB%E9%87%8C%E9%9D%A2+%E9%80%89%E9%82%A3)
这道题选什么.一定要告诉我为什么.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.