Which of the following is a valid declaration of a char?char ch = '\utea';char ca = 'tea';char cr = \u0223;char cc = '\itea';
Question
Which of the following is a valid declaration of a char?
char ch = '\utea';
char ca = 'tea';
char cr = \u0223;
char cc = '\itea';
}
Solution
The valid declaration of a char is: char cr = '\u0223';
Explanation:
-
char ch = '\utea'; - This is not valid because '\utea' is not a valid unicode escape sequence. Unicode escape sequences consist of '\u' followed by exactly 4 hexadecimal digits.
-
char ca = 'tea'; - This is not valid because 'tea' is more than one character. A char can only hold a single character.
-
char cr = '\u0223'; - This is valid. '\u0223' is a valid unicode escape sequence.
-
char cc = '\itea'; - This is not valid because '\itea' is not a recognized escape sequence or unicode escape sequence.
Similar Questions
Which of the following declaration is not supported by C language?String str;Both “String str;” and “float str = 3e2;”float str = 3e2;char *str;Clear my choice
Which one of the following is a valid statement? char[] c = new char();char[] c = new char[5]; char[] c = new char(4); char[] c = new char[];
Which one of the following declarations is correct?Select one:int long;char int;int length;float double;
Choose a valid identifier name according to the naming rules of the C language.
Which of the following will result in a compile-time error? float f = 1.3; char c = 'A'; byte b = 10; boolean b = true;
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.