String Literals
Group of characters enclosed in double quotes is called as String literals.Example:String s=”Webnoid”; They may not contain new line or line feed.
Char Literals
A char literal can be represented as single character with single quotes.Example:1. char c=’a’; //(valid)2. char c=”a”; //(invalid)3. char c=a; //(invalid)4. char c=’abc’; //(invalid) Char literal can also be specified [ … ]
Boolean Literals
Boolean type values are true or false only in lower case.Example:1. boolean b=false; //(valid)2. boolean b=0; //(invalid)3. boolean b=False; //(invalid)4. boolean b=”false”; //(invalid)
Floating Point Literals
Floating point literals is by default double type. But it can be explicitly as float type by suffixing with f or F.Example:float f=123.546; //(invalid)float f=123.546f; //(valid)double d=123.546; //(valid) Floating point [ … ]
Integral Literals
For the integral data types we can specify literal value in the following ways.1) Decimal Literals: It allows 0 to 9 digits.2) Octal Literals: It allows 0 to 7 digits. [ … ]
Literals
Any constant value which are assigned to the variables are called literal. Example:int x=10 int —-> datatype|keywordx ——-> name of variable|identifier10 —–> constant value|literal
Char Data Type
Char Data Type:In previous languages like C and C++ are ASCII code based the number of ASCII code characters are <256 to represent these 256 characters 8-bits enough hence char [ … ]
Boolean Data Type
Boolean Data Type:Size: Not applicable (virtual machine dependent)Range: Not applicable but allowed values are true or false.