Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Reg Character Literals

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic