1

Fun Java test:

Without looking up anything, answer the following question:

Which of the following variable identifiers is legal in Java and why?

1) float $50.00;
2) float $50_00;
3) float 50;
4) float else;

Comments
  • 2
    I'd say 2)
    Underscore is legal and I think period is not. And the $ character is used internally for anonymous classes and the like so I'd bet that is legal too.
  • 0
    @cafecortado Well done, well done... Yes, 2) is correct. And indeed, period is not legal, while underscore and $ are.
  • 1
    Came here to make the same guess as @cafecortado

    It makes sense that . is not legal, otherwise it would conflict with the member access syntax.
  • 1
    @Lensflare Thanks for participating. Well spotted.
  • 0
    This is for the OCA by the way. lmao
Add Comment