wood burning stoves 2.0*
The moose likes Mock Exam Errata and the fly likes Boone Exam question 70 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Boone Exam question 70" Watch "Boone Exam question 70" New topic
Author

Boone Exam question 70

Peter Chirco
Greenhorn

Joined: Nov 20, 2001
Posts: 4
I have a question about shifting
Question 70: To place a 1 in the high-bit of an int named ref that�s set to 0x00000001, you can write:
Select the one right answer.
A. ref >> 31;
B. ref >>= 31;
C. ref << 31;
D. ref <<= 31;
E. Shifts the bits in an integer to the left by the number of F. bits specified and fills the right-most bit with 1.
F. Shifts the bits in an integer to the left by the number of bits specified and fills the right-most bit with 0.
The answer as given in the test is d, but I thought the answer was c. I looked through the Robert Heller and Ernest book, and I cannot find a <<= shift operator anywhere.
Thanks
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
if you use what proposed in c, then the result of the expression is lost since it is not reassigned. Since the question explicitely asks to "place a 1 in the high bit of an int named ref" you have to reassign the result to the variable ref and thus the only possible answer is d.
the operator <<= is what is called a compound assignment operator and a <<= b is equivalent to a = a << b
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
sadesh
Greenhorn

Joined: Dec 01, 2001
Posts: 1
Originally posted by Peter Chirco:
I have a question about shifting
Question 70: To place a 1 in the high-bit of an int named ref that�s set to 0x00000001, you can write:
Select the one right answer.
A. ref >> 31;
B. ref >>= 31;
C. ref << 31;
D. ref <<= 31;
E. Shifts the bits in an integer to the left by the number of F. bits specified and fills the right-most bit with 1.
F. Shifts the bits in an integer to the left by the number of bits specified and fills the right-most bit with 0.
The answer as given in the test is d, but I thought the answer was c. I looked through the Robert Heller and Ernest book, and I cannot find a <<= shift operator anywhere.
Thanks


sadesh
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Boone Exam question 70