• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How tricky are the questions

 
Ranch Hand
Posts: 458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I came across this question, in a mock exam...
Which of the following expressions results in a positive value in x?
A. int x = -1; x = x >>> 5;
B. int x = -1; x = x >>> 32;
C. byte x = -1; x = x >>> 5;
D. int x = -1; x = x >> 5;
The answer is A, but C got me wondering. It is not legal syntax and does not compile, as is. You have to cast x in order to get the line to work.
byte x = -1; x = (byte)(x >>> 5);
It still results in a negative and would not be a correct choice, however, what if it would have been a correct choice? Do the questions get that tricky? The question was not about legal syntax, yet there was some illegal code in the answers.
My thought was that it is an error on the test author's part, but it made me wonder.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are no trick questions on the exam. Each question is carefully worded (and nitpicked) to insure that anyone who understands the concept can correctly identify the correct answer(s) without having to quess what the authors intended.
That doesn't mean that I didn't mess some up because I didn't read carefully enough .
 
reply
    Bookmark Topic Watch Topic
  • New Topic