write a
a notes on different type of literals 5mark
Answers
Answer:
There are five types of literals in Java.
Integer Literals
Boolean Literals
Character Literals
String Literals
Floating Point Literals
Explanation:
1) integer
The integer literal can be used to create int value. They can be used to initialize the group data types like byte, short, int and long.
2)boolean
The Boolean literal is used to represent the two values i.e. either true or false. We can assign the true or false value to the variable. These values are case sensitive.
3)character
The character literal is a 16 bit Unicode character where it is enclosed in single quotes. It use primitive data type char.
4)string
The string literal are the sequence of characters which are enclosed in double quotes. The string literal should occur in single line.
5)floating point
The floating point literal can be used to represent the decimal values with a fractional component. These literals are double data type. These literals contain the fractional parts and if the floating point literal is suffixed with letter f or F then it is float type.
These literals include the float and double data types. In floating point literals double is the default data type. To represent the float literal f is suffixed and to represent the double literal d is suffixed.