ICSE Class 9 Computer Applications
3. Values and Data Types
01 Token and its types
Token is the smallest individual elements, also known as the building blocks of a Java program.
Java supports five types of tokens which are:
• Keywords are predefined or reserved words that have special meaning to the Java compiler. Eg. if, for etc.
• Identifiers are the user-defined names of variables, methods, classes, arrays etc.
Rules to be followed while naming the identifiers such as:
• Identifiers must begin with a letter, dollar sign or underscore.
• Apart from the first character, an identifier can have any combination of characters.
• Identifiers in Java are case sensitive.
• Java Identifiers can be of any length.
• Identifier name cannot contain white spaces.
• Any identifier name must not begin with a digit but can contain digits within.
• Most importantly, keywords can’t be used as identifiers in
• Literals
Java.Literals are similar to normal variables but their values cannot be changed once assigned.
In other words, literals are constant variables with fixed values.
These are defined by users and can belong to any data type.
Java supports five types of literals which are as follows:
• Integer
• Floating Point
• Character
• String
• Boolean
• Punctuators
Special symbols are a few characters which have special meaning known to Java compiler and cannot be used for any other purpose. For example: { } [ ] ; ,
• Operators
Operators in Java is a symbol which is used to perform operations.For example: +, -, *, / etc.
​
02 Escape sequence
​
\n for printing a new line.
​ \t to give a tab between two words.
\\ for printing a backslash on the text string
\" for printing a double quotation mark on the text string
\' for printing a single quotation mark on the text string
03 java character set
Unicode System Unicode is a universal international standard character encoding that is capable of representing most of the world's written languages.
Java uses Unicode character set to support multiple languages.
​
​
04 Data types
Data types specify the different sizes and values that can be stored in the variable.
There are two types of data types in Java:
• Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double.
• Non-primitive data types: The non-primitive data types include class and array.
​
05 Variables and constants
​
Declaration of variables datatype variablename eg. int i;
Initialization of variables eg. i=10;
Constant – keyword final before variable declaration makes it a constant. Hence, its value can’t be changed in the program.
eg. final double TAXRATE=0.25;
final double PI=3.14;
​
06 Conversion
Process of converting one predefined type into another.
Two types of type conversion
•Implicit type – conversion performed by compiler without programmer’s intervention.
•Explicit type – user-defined conversion that forces an expression to be of specific type.
Eg. (float) (x+y/2)
​​