Thursday, July 09, 2009

Programming IQ test

While the test is purely for fun, I have to comment on my score, which is no better than 75%. I got my bragging rights, though :-)

Many of the questions I got right are just as unimportant than the ones I got wrong.

The worst offender for suckers like me who takes this nonsense very seriously, are:

Question 6: Your local supermarket is all sold out of energy drinks, Jolt Cola, and Mountain Dew. Which beverage will keep you going, packing the most caffeine and sugar into a 12-ounce can?

Correct Answer: Sunkist Orange Soda

Your Answer: Dr. Pepper

Sunkist Orange contains just as much caffeine as runner-up Dr. Pepper but surpasses it in sugar content.

I mean, are programmers only located in the North of America? I live in Norway, which may very well compare to living under a rock. It certainly looks that way on certain government decisions. But that’s a Law of Nature, I guess.

But I digress. WTF is Sunkist Orange Soda? And haven’t people heard of coffee? Need more caffeine? So up the dose! Need sugar? No you don’t, but anyway, what’s stopping us from adding as much sugar as the coffee mug can absorb?

I think I am proud of failing #6.

Then there is, and this is the stupidest, as it contains no correct answer. I failed this one on purpose, because I had to answer something:

Question 12: Which of the following is the best way to write reusable code that is easier to maintain?

Correct Answer: Insert comments throughout your source code files

Your Answer: Use more global variables

Documenting your code is the best way to ensure that another programmer can understand it. All the other choices are recipes for disaster.

People who know me professionally, know I am a test infected kind of guy. Along with Test Driven Development comes Merciless Refactoring, and that is the correct answer. That is, both of them. Code comments are one of the hardest thing to get right, simply because they have to address the code at an abstract level. That is the only way to write comments which will stand the test of time. Most comments simply repeats what the code does, not why. Our variable-, method-, and class-names should do that.

I opted to comment on #16, simply because I hate to be wrong:

Question 16: A client has asked you to write some basic accounting software in C. What data type is best for representing figures in dollars and cents?

Correct Answer: Integer

Your Answer: Double

Integers can be used to implement fixed-precision math. Floating-point numbers, whether single or double precision, aren't accurate enough to keep track of finances.

I flunked this one. Badly. However, the question itself is ill-phrased. The available answers only refer to the type “Integer”, while it should be a set of integers. This is my opinion, though. I can see how one integer can solve the problem: Just look at any financial number and pretend there is always two fractional digits, or four if one need this kind of precision. In financials, we do. Then we pretend that the first two, or four, digits always represents the cents. But then we have greatly reduced the highest value possible to address. Better hope we never have to address Zimbabvian dollars with that software package.

No, the correct answer must be some composite of multiple integers: One for the cents, and one or more for the dollars.

Would I be a better programmer if I knew Kernighan’s best known achievement? Maybe. Or maybe not:

Question 17: For what achievement is Brian Kernighan best known?

Correct Answer: He was co-creator of AWK, a programming language for text processing

Your Answer: He was co-creator of the C programming language

Kernighan is known as the "K" in the K&R C language specification, but he didn't create the language; he just helped Dennis Ritchie document it.

In the same category: I didn’t know what “Turing complete” meant until #18. Who cares? And I don’t know about standard SQL, does that even exist as an implementation? All I know, is that loops are possible in T-SQL. And for PostScript? I thought that was a markup language, like HTML and XML:

Question 18: A programming language is said to be "Turing complete" if it can be used to implement any conceivable algorithm. Which is NOT a Turing-complete language in its standard form?

Correct Answer: SQL

Your Answer: PostScript

Standard SQL can't do loops, although you can get Turing completeness with proprietary extensions to the language from certain vendors.

That said, the questions I got right, by pure chance or otherwise, there are a few that doesn’t tell anything about programming skills:

  • Question 1: What is the relationship between Java and JavaScript?
  • Question 2: Hungarian Notation is a variable-naming convention used by some programmers. How did it get its name?
  • Question 3: Just-in-time (JIT) compilation improves the performance of languages that compile into bytecode. Which language featured the first JIT compiler?
  • Question 4: If I told you a key characteristic of my programming language of choice was that it generated threaded code, which language would I most likely be talking about?
  • Question 5: Once very popular and widely used, Pascal spawned a number of derivative languages. Which is NOT a successor to Pascal?
  • Question 7: What is the best way to preserve type safety in assembly language?
  • Question 8: Which of the following is NOT a central tenet of extreme programming?
  • Question 9: Why are race conditions a problem in modern software development?
  • Question 10: Why do some consider Ruby to be more "purely" object-oriented than other, more popular OOP languages such as Java and C++?
  • Question 15: Is P equal to NP?
  • Question 19: Which group has had the most impact on modern object-oriented programming practices?
  • Question 20: Which of the following is NOT a data structure used in modern programming practice?

There must be something wrong with me: Out of 20 questions, these are the only three I find useful:

  • Question 11: Failure to validate user input is one of the most common sources of software security vulnerabilities. When is it safe to accept user input without validation?
  • Question 13: Of the following, who is NOT the inventor of a programming language in current use?
  • Question 14: To what concept does "the mythical man-month" refer?

Take the test at InfoWorld.

1 comment:

online iq test said...

Thank you for these very information.The were useful for me. Looking forward to read your next post. online iq test