• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Valid declarations?

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Mughal's "A Programmer's Guide to Java Certification" to study for the SCJP 1.4 exam and I had a question if someone can help.
On the Review question section of p.33, question as stated:
Select all valid answers:
(a) char a = '\u0061';
(b) char \u0061 = 'a';
(c) ch\u0061r a = 'a';
Answer: All are valid declarations.
Why would (c) ch\u0061r a = 'a'; be considered valid?
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is valid because unicode notation is actually translated prior to compilation of the program. Therefore, the line:

is first translated to this:

which is obviously valid prior to compilation.
I hope that helps,
Corey
 
Linda Pan
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see ...
Thank you.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For more information about lexical translations, please check out: JLS 3.2 Lexical Translations
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic