Non-graphic characters in Java.

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:

Escape Sequence

Non graphic Character

\a Audible bell (alert)
\b Backspace
\f Formfeed
\n Newline or linefeed
\r Carriage Return
\t Horizontal tab
\v Vertical tab
\\ Backslash
\’ Single quote
\” Double quote
\? Question mark
\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)
\0 Null


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.


Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: