Page 39 - CA_Blue( J )_Class10
P. 39
You will get the following output:
3.4 TOKENS
A Java program may contain thousands of lines of code. Each of these codes is written using Java tokens. A token is
considered the smallest individual element in a Java program that has a meaning. Tokens are also known as the building
blocks of a Java program.
Tokens are something equivalent to the cells of a living organism
which are the basic building blocks of all living things. Similarly, Definition
tokens are the smallest elements that can be identified by the Java
compiler. All Java expressions and statements are constructed Tokens are the smallest units of code that the
by tokens. The compiler reads the source code when we try to Java compiler recognizes as meaningful and
compile a program, and then extracts individual Java tokens syntactically correct.
and translates them into Java byte codes which are executed
according to their meaning. They are also useful for compilers to detect errors.
There are various types of tokens that are used by the Java compiler which are as follows:
• Keywords • Identifiers • Literals
• Operators • Punctuators
Let us learn about these in detail.
3.4.1 Keywords
Keywords are reserved words that have pre-defined meaning in the Java compiler for a specific purpose. We cannot
use Java keywords as variable names. If you try to use keywords as variable names, then the Java compiler will give an
error message. A list of keywords used in Java is given below:
abstract do if private this
assert double implements protected throw
boolean else import public throws
break enum instanceof return transient
byte extends int short true
case false interface static try
catch final long strictfp void
char finally native super volatile
class float new switch while
const for null synchronized continue
default goto package
37
Values and Data Types 37

