Thursday, January 26. 2006Trick QuestionsTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Ah, thanks for the clarification Des. I had an inkling that the wisdom of using the questions in that other blog post as a peer guidance might have been a little questionable.
im suprised by the answer 31 for the top piece of code.
is that a double trick question or a typo?
A very good point Des. I'm a firm believer that, when used in a limmited way, trick questions can be usefull but like you said over-use in exams is a really bad idea. They can, however, serve a very usefull function if used AND EXPLAINED IN DETAIL in lectures. When students can work through a trick question and not be confused then you have really thought them the language. It's all about using them right and in moderation. Get it wrong and you will just confuse, depress and disshearten your students and that is absolutely not the point.
No, its 28, and thats the trick.
Any integer beginning with a zero in Java is treated as an octal (i.e. base 8), so 013 actuallys is (1x8) + (3x1) == 11. As I said in the post, if someone gets this answer right, I can safely assume they know a bit of Java, but if someone gets it wrong, it's wrong to assume anything. Thanks for reading
i just like to point out that the octal result you used to calculate 28 is wrong.
You wrote:(1x8) + (3x1) == 11 Actually the answer is 8+2+1 = 11 thats cos the octal for 013 is: 000001011
Hi Tony,
I think you're confusing Octal and Binary. Counting in Octal means that all numbers are represented using the digits 0-7, to represent varying powers of 8. 1011 is binary for 11, that is true but 13 is octal for eleven, and Octals is what I was talking about here. Just so ya know. Des
I realize this article is old but I felt compelled to comment on it. I have been breezing through college Computer Science classes that seem to test just these kinds of questions.
First it started in high school with the Computer Science AP exam. An exam meant for high school students to receive College level credit. It was basically a big exam with these exact questions. I was told up front that points would be taken off for using .length or .size() inappropriately. Not a problem for me, I liked syntax tricks, they are easy for me... but what does this have to do with Computer SCIENCE. Seems like the same thing in college. A third year class, introducing C++ had us actually write some Object Oriented programming project (ohhhh) but what showed up on all of the test? Not an algorithm question, nothing about deciding which data structure to use and how to go about it, instead we have "find the error in this code" and "explain what this code means '**ptr++;'." This actually leads to the other arguments I have seen on the Internet... the serious degradation of quality programmers. I haven't felt challenged, nor have I even been presented with a real challenge at college and I find it almost shameful. When did Computer Science go so wrong? To maybe clear it up the math a little more, Octal is base 8. That means to convert to our usual base 10 you would perform the following. The right most digit's decimal value is (digit x 8^0). That is 8 to the zeroth power. Followed by the next digit (digit x 8^1) meaning 8 to the first power. Continuing to increment the power of 8 for each digit. Just like binary, just like any "base" number. Therefore: Octal 013 = (1 x 8^1) + (3 x 8^0) = (1 x 8 ) + (3 x 1) = 8 + 3 = 11 (Decimal) ---- 1) Comments don't seem to like astericks. 2) An '8' followed by a ')' produces a smilie =) |
About:Switch to Dark on Light!
This website is the online diary of me, Des Traynor, a User Experience Researcher in Dublin, Ireland. I work with Contrast. I usually write on 5 topics: I update about 3-4 times per month. Be sure to subscribe so you don't miss this good stuff. If this is your first time here, check out the archives.My official homepage provides more information about who I am, and what I research. You can contact me at destraynor [at] gmail [dot] com Quicksearch |