File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes From Dan's exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "From Dan Watch "From Dan New topic

From Dan's exam

Damien Howard
Ranch Hand

Joined: Apr 01, 2003
Posts: 456
Can someone please explain why or how 2 and 3 are considered in octal format?

Question 7
class D {
public static void main (String[] args) {
char a = 061; // 1
char b = '\61'; // 2
char c = '\061'; // 3
char d = 0x0031; // 4
char e = '\u0031'; // 5

Thank you.
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
You can read the format of the octal escapes in JLS 3.10.6
[ July 06, 2003: Message edited by: Jose Botella ]

SCJP2. Please Indent your code using UBB Code
Brian Joseph
Ranch Hand

Joined: May 16, 2003
Posts: 160
Didn't know about those, but I have a feeling that would be a bit too esoteric for the exam itself, but still interesting to know.
Damien Howard
Ranch Hand

Joined: Apr 01, 2003
Posts: 456
Perhaps it isn't on the exam, but it is tough to know, as all the mock exams seem to include a few items that aren't on the exam, at least so people say. Since I haven't taken it yet I'm paranoid as to what will really be on the exam and how hard the real questions are.
It is sorta covered in the JavaRanch Style Guide.
subject: From Dan's exam
It's not a secret anymore!