Page 41 - CA_Blue( J )_Class10
P. 41
literals, octal integer literals and hexadecimal integer literals. For example, 10101, 27, 0xA2 (Where 0x is used for
numbers representing hexadecimal integer literals).
Floating-Point Literals
A floating-point literal is a real number or a number with a decimal point. It may be a positive or a negative value. It can
only be specified in decimal forms and not in octal or hexadecimal forms. For example, 2.5, 0.235, 1.0E-3, 3f (where f
is used to take float value).
Note: By default, decimal numbers without 'f' are considered as double values by Java compiler.
Character Literals
A character literal is a single character like a letter or a symbol or a digit enclosed within single quotes.
For example, 'C', '&' and '6'.
String Literals
A string literal is a sequence of characters enclosed within double quotes. For example, "India" and "Computer
Application of Class 10".
Note: In Java, single quotes can only contain one character, with escape sequences if necessary. You need
to use double quotes for strings, for example:
char foo = 'm';
String greetings = "hello!";
Boolean Literals
They allow only two values either true or false.
The null Literal
The null literal is a special Java literal that represents a null value. It cannot be assigned to a primitive type such as int,
float, etc. but can be used to initialize an object or reference variable. For example:
String s= null;
We will learn more about primitive and non-primitive(reference) data types later in this chapter.
3.4.4 Operators
An operator is a special symbol that signifies the compiler to perform some specific mathematical or
non-mathematical operations on one or more operands. For example:
5 + 6 = 11
Where '+' is an operator which performs the addition operation between two values 5 and 6. The '=' is also an operator
which returns the result performed by the '+' operator. Java supports the following types of operators:
Operators Category Operators
Arithmetic Operators +, –, *, /, %
Assignment Operators =, +=, -=, *=, /=, %=
Relational Operators >, <, >=, <=, ==, !=
Logical Operators &&, ||, !
Unary Operators ++, --
Ternary Operator ?, :
We will learn more about operators in the next chapter.
39
Values and Data Types 39

