programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Type in question and octal values

Manish Hatwalne
Ranch Hand
Posts: 2596
I thought it is more appropriate to show octal variables as a sequence of three digits, if they have only 1 digit in them (values 0 to 7), but yesterday when I keyed in value 007 for decimal 7 in one of the mocks, it was assessed as an incorrect answer in favour of 07. Is this a preferred way? Moreover, will 007 (or similar) be treated as an incorrect answer in the actual exam?
eg- what is decimal 15 in hex?
Is it 0xF or 0x0F?
I am used to writing it as 0x0F. Should I stick to it or go for 0xF?
TIA,
- Manish
[ March 18, 2002: Message edited by: Manish Hatwalne ]

Jamal Hasanov
Ranch Hand
Posts: 411
Hi, Manish
0x0F and 0xF values are equal.
You can test it so
public static void main(String [] args) {
int a = 07;
int b = 007;
int c = 0xF;
int d = 0x0F;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
}
That's all. If you're preparing for SCJP exam, you should try everything with java code. because this way, you are understanding basic principles deeply.
Jamal

Manish Hatwalne
Ranch Hand
Posts: 2596
Originally posted by Jamal Hasanov:
Hi, Manish
0x0F and 0xF values are equal.
You can test it so
public static void main(String [] args) {
int a = 07;
int b = 007;
int c = 0xF;
int d = 0x0F;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
}
That's all. If you're preparing for SCJP exam, you should try everything with java code. because this way, you are understanding basic principles deeply.
Jamal

Jamal,
I *DO* understand they are same values
What I am referring to is "Type in" type of questions of the exam, where you are required to enter the answer by typing it in the TextField, in which case how you enter it *DOES* matter, and as I said earlier my answer 007 was assessed as an incorrect answer in favour of 07 by the mock engine; hence the question.
Regards,
- Manish

Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
The question will make it very clear about how you should type the value in.
For instance it may say something like, type in the octal reprensentation of 16. Do not enter unneeded zeroes or spaces.
so the answer is clearly 020 because the first zero is to indicate an octal literal and the last one is part of the value.
[ March 19, 2002: Message edited by: Valentin Crettaz ]

Manish Hatwalne
Ranch Hand
Posts: 2596
Originally posted by Valentin Crettaz:
The question will make it very clear about how you should type the value in.
For instance it may say something like, type in the octal reprensentation of 16. Do not enter unneeded zeroes or spaces.

Great!
Thank you
- Manish