Q3. Can non-graphic characters be used and processed in Java? How? Give examples?
Ans. Yes, Java allows certain non-graphic characters in character constants. Non-graphic characters are those characters that cannot be typed directly from keyboard. Example, backspace, tabs, carriage return etc. These non-graphic characters can be represented by using escape sequences. n escape sequence is represented by backslash (\) followed by one or more characters.
Following table gives a list of escape sequences:
Non graphic Character
|\a||Audible bell (alert)|
|\n||Newline or linefeed|
|\0n||Octal number (0n represents the number in octal)|
|\xHn||Hexadecimal number (hn represents the number in hexadecimal)|
|\uHn||Unicode character Octal represents through its Hexadecimal code Hn)|
These characters can be typed from the keyboard but when used without escape sequence, these carry a special meaning and have a special purpose, however, if these are to be typed as it is, then escape sequences should be used.