What are the Java tokens?

Java tokens mean the smallest individual units in a program. It includes five types of tokens:
1. Keywords.
2. Identifiers
3. Literals
4. Operators
5. Separators
1. Keywords: The words which are reserved in a language for specific purposes are known as Keywords. These keywords are written in lower-case (small letters). Their meaning and their functions are already known to the compiler. Java has 50 keywords. Since different keywords are used for different purposes they cannot be used as an identifier for variables, classes, methods etc.

2. Identifiers: Identifiers are the names given to the variables, classes, methods, objects, labels and interfaces in program Java identifiers follow the following rules:
1. It should not be a keyword which is available in the language.
2. First character of identifier should be an alphabet or underscore.
3. No other special character is allowed except underscore (_).
4. Both the cases that are upper case and lower case are allowed. An identifier student is not same as STUDENT.

3. Literals (Constants): Literals are used to store constant values (that cannot be changed) in variables. They are a group of characters which can be letters, digits etc. There are five types of literals in Java. They are:
1. Integer literals
2. Floating point literals
3. Character literals
4. String literals
5. Boolean literals.

4. Operators: Operator specifies which operation to be performed on the variables in an expression. Different operators perform different kinds of operations.
1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Assignment operators
5. Increment and decrement operators
6. Conditional operators
7. Bitwise operators
Special operators like instance of and dot operator (.)

5. Separators: Separators are basically used to define the structure of the source code.
E.g. parentheses () – used for sending and receiving arguments in a function.
braces { } – used for assigning values to array at the time of its declaration and also used for block of statements.
Brackets [ ] – used for declaring array and accessing its elements
Semi color; – used at the end of every line

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.