How are Decimal, Octal and Hexadecimal integer literals represented in Java?

Question :

How are Decimal, Octal and Hexadecimal integer literals represented in Java?

Decimal Integer Literals uses digits from 0 to 9 (i.e. 10 digits this is what you normally use to represent numbers in mathematics) but should not be prefixed with 0. + (or no symbol) or – may be used to represent positive or negative numbers respectively. Thus -12, 56, or +75 may be considered to be Decimal Integer Literal.

Octal Integer Literals uses digits from 0 to 7 (i.e. 8 digits) and should be prefixed with 0. + (or no symbol) or – may be used to represent positive or negative numbers respectively. Thus -012, 056, or +075 may be considered to be Octal Integer Literal.

Hexadecimal Integer Literals uses digits from 0 to 9 and alphabets from A (or a) to F (or f) representing 10 to 15 (i.e. 16 numbers) and should be prefixed with 0x or 0X. + (or no symbol) used to represent positive numbers or – may be used to represent negative numbers. Thus -0x12, 0X56, or +0A7F5 may be considered to be Hexadecimal Integer Literal.


Latest Current Affairs 2026 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad