Page 40 - CA_Blue( J )_Class10
P. 40
Note: Some keywords like const and goto are not in use currently. They are reserved for future use.
3.4.2 Identifiers
Identifiers are the names given to different components of a Java program like class, variables and methods. It can
be a combination of letters and numbers or simply a sequence of letters. Keywords cannot be used as identifiers. An
identifier must differ in spelling or case from any keyword. After an identifier is declared it can be used later in program
statements to refer to the associated value.
Identifier Naming Conventions
Following are some protocols that are followed while naming the identifiers:
• An identifier must start with a letter (a–z or A–Z) or underscore (_) or dollar ($).
• An identifier does not start with a digit. However, apart from the first character, it can have any combination of
letters or digits.
• An identifier is case-sensitive which means "AGE" and "age" are two different identifiers.
• An identifier can be of any length.
• An identifier cannot contain whitespaces.
• An identifier cannot be a Java keyword.
• An identifier must not contain any type of special symbol apart from underscore (_) or dollar ($) sign.
Examples of Valid Identifiers
According to the protocols of identifiers naming, some of the valid identifiers are:
Name, $add, _cost, marks_computer, country_91, etc.
Examples of Invalid Identifiers
According to the protocols of identifiers naming, some of the invalid identifiers with reasons are:
Invalid Definition
Identifier Reason for Invalidity
91country An identifier cannot start with a number. Identifiers in Java are a sequence of characters
to identify something in a program. They are
cost price An identifier cannot contain whitespace. names given to a class, variable, package,
s+p An identifier must not contain any special method, or interface and allow the programmer
symbols apart from $ and _. to refer to the specific item from any place in
class An identifier cannot use a keyword. the program.
3.4.3 Literals
Literals are the values that can be stored in the variables. Unlike variables, they cannot change once assigned.
So, literals are also called constants. There are six types of literals which are:
• Integer Literals • Floating-Point Literals
• Character Literals • String Literals
• Boolean Literals • The null Literal
Let us learn about them in detail.
Integer Literals
An integer literal is a whole number or the number without a decimal point. It may be a positive or a negative value.
There are four types of integer literals supported by the Java language which are decimal integer literals, binary integer
3838 Touchpad Computer Applications-X

