Page 61 - TP_iPlus_V2.1_Class8
P. 61
• An identifier cannot start with a digit.
• Keywords cannot be used as an identifier.
• No special symbols like !, @, #, %, etc. can be used in an identifier.
• Identifiers are case-sensitive, which means ‘name’ and ‘NAME’ are two different identifiers.
Examples of some valid identifier names are Employee123, mygood_book, _address93, FirstName,
age, etc.
Examples of some invalid identifier names are 1_Name, @Address, 1234, –Age, etc.
Keywords
Keywords are the reserved words that cannot be used as identifier names as they carry a special
meaning for the Java compiler. Some of the Java keywords are given below:
Java Keywords
abstract class final interface static
assert const float long switch
boolean continue for new this
break default if private throw
byte do implements protected throws
case double import public try
catch else instanceof return void
char extends int short while
Although reserved as a keyword in Java, const is not used and has no function.
There are three more reserved words in Java: true, false, and null. Technically, they are literal
values and not keywords. However, they cannot be used as identifiers, and they have a specific
meaning to the Java compiler.
Data Types
A data type is used to define the size and type of value that a variable can store. The Java
language is rich in its data types. Java provides two types of data types: primitive and
non-primitive.
Primitive Data Types
Java provides eight basic data types, which are as given in the following table:
Data Type Size (in bits) Minimum Value Maximum Value
byte 8 –128 127
short 16 –32768 32767
int 32 –2147483648 2147483647
long 64 –9223372036854775808 9223372036854775807
char 16 0 65535
float 32 1.4E –45 3.4028235E38
59
Program Coding

