This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg Character Literals

 
Vishnu Munnangi
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

This is a question from one of the mock exams.
please go through the code...

Which character(s) will be correctly declared and initialized?
(Select two correct answers)

public class Test002 extends Super
{
public static void main(String args[])
{
char c1 = '\u00AA';
char c2 = '\u00DD';
char c3 = '\u000D';
char c4 = '\u000A';
}
}

class Super
{
final void m() { }
}

A: c1 and c2.
B: c3 and c4.
C: only A is correct.
D: only B is correct.
Answers given are A,C.

My question is whether we have to remember character literals for escape sequences for the SCJP exam.
I know that escape sequences are '\b', '\f', '\n','\r','\t','\\','\'','\"'.
Is that all sufficient or we need to remember their literal representation too.
That is '\u000A' is for new line
and '\u000D' is for return etc.,

Thanks in Advance.
 
Gurpreet Singh
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishnu, along with escape sequences you mentioned, you do only need to remember that '\u000A' and '\u000D' cannot be correctly used as characters, better use \n \r in place of them. That's it.

I suggest you go through this test :
www.danchisholm.net\july21\topic\section4\literals1.html
[ October 19, 2004: Message edited by: Gurpreet Singh ]
 
sashi balu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan had the foll. tip(or rather phrase) to remember the escape sequences apart from '\\','\'','\"',

"B"ig "F"arms "N"eed "R"ed "T"ractors ( '\b', '\f', '\n','\r','\t').

Hope that helps
Sashi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic