• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Unicode Constant what ??

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the statement to assign a unicode constant CODE with 0x30a0?
Answer:
public static final char CODE='\u30a0';
Can something like this be on the test, Has anyone seen it?
 
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
Yes it could...
Why wouldn't it be possible to get a question like that?
 
Paul Salerno
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Valentin,
Because I've never seen it. I've been thru a 4 month course on Java, although they crammed everything into it, including jsp, swing and servletts.
I was wondering if its possible or not.
 
Valentin Crettaz
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
From JLS 3.1 Unicode


Programs are written using the Unicode character set. Information about this encoding may be found at:
http://www.unicode.org
...
Except for comments (�3.7), identifiers, and the contents of character and string literals (�3.10.4, �3.10.5), all input elements (�3.5) in a program are formed only from ASCII characters (or Unicode escapes (�3.3) which result in ASCII characters). ASCII (ANSI X3.4) is the American Standard Code for Information Interchange. The first 128 characters of the Unicode character
encoding are the ASCII characters.


Also, read JLS 3.2 Lexical Translations
HIH
[ January 29, 2002: Message edited by: Valentin Crettaz ]
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is actually a stated testing objective, under language fundamentals:
"State the range of all primative data types and declare literal values for String and all primitive types using all permitted formats, bases, and representations."
That "all...representations" covers unicode characters.
Rob
[ January 29, 2002: Message edited by: Rob Ross ]
 
Paul Salerno
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob, looks like I'll get that one wrong.
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why? What don't you understand about unicode characters?
Rob
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul :
You are not expected to know the unicode character for A, or Q or Z etc.
The exam will questions where they assign different values to a char variable and you have
to identify valid assignments
You may see some thing like this and have to select valid statements
char c ="A" ;
char c = A;
char c='D";
char c = '\uXXXX';
char c='\uXXXXX';
The third and fourth are valid assignments. I am using XXXX to denote hes letters/numbers here.
If there was an example with real X's that would be wrong off course.
HTH
 
Valentin Crettaz
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
Paul,
here is an applet you may want ot play with a little:http://java.sun.com/j2se/1.4/docs/guide/awt/demos/symboltest/actual/index.html
HIH
 
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shivaji Marathe:
Paul :
You are not expected to know the unicode character for A, or Q or Z etc.
You may see some thing like this and have to select valid statements
char c = '\uXXXX';
HTH



Just in case you didn't already know, the following would give a compile error because of the way the compiler translates Unicode literals early on in the compilation process:
char c = '\u000A'; // linefeed character
Will make the compiler see the statement as
char c = '
';
and spit out a message like "invalid constant value" or something like that.
Junilu
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic