0 votes
in JAVA by
Which of the following is a valid long literal?

i) ABH8097

ii) L990023

iii) 904423

iv) 0xnf029L

1 Answer

0 votes
by

iv) 0xnf029L

Reason: For every long literal to be recognized by Java, we need to add L character at the end of the expression. It can be either uppercase (L) or lowercase (l) character. However, it is recommended to use uppercase character instead of lowercase because the lowercase (l) character is hard to distinguish from the uppercase (i) character.

For example,

  1. Lowercase l: 0x466rffl
  2. Uppercase L: 0nhf450L

Related questions

0 votes
asked Apr 10, 2021 in JAVA by Robindeniel
0 votes
asked Apr 8, 2021 in JAVA by SakshiSharma
...