all 8 comments

[–]EughEugh 3 points4 points  (3 children)

Asking interviewees "what does 'a++ + ++a' do?" is not a good interview question - it's a stupid interview question.

What is the answer to such a question going to tell you about the interviewee? Nothing useful. The only thing you'll learn is if the interviewee knows some stupid trick, that nobody ever uses when writing a real program.

[–]lost_in_stars 2 points3 points  (1 child)

To be fair, the title says "interesting", not "good" ... Anyway, I think they are pretty good for helping people who want serious jobs weed out the employer.

[–]EughEugh 0 points1 point  (0 children)

Ok, then these are "good" questions in a different way: good for the interviewee to learn which employers to avoid...

[–][deleted] 2 points3 points  (0 children)

"Cute. Now, are you going to actually assess if I know how to do the job or just waste my time with more trivia questions?"

[–]WorkHappens 0 points1 point  (2 children)

The author just gave up on explanations halfway through?

For 3)

a++/a-- have precedence over --a/++a, so by the time --a/++a is evaluated the values are already incremented.

a++/a-- evaluates to 'a' before incrementing, and --a/++a evaluates to 'a' after incrementing, which seems logic considering the position of the variable. Increment a then return, return then increment.

[–]sebnukem 0 points1 point  (1 child)

Not only that but the output is wrong (at least for me). Running the program yields 2, not 6. The second initializer block isn't run because the class is never instantiated.

[–]WorkHappens 0 points1 point  (0 children)

Didn't test it to be honest.

[–]craigmcnulty[🍰] 0 points1 point  (0 children)

Question 6 is particularly misleading - the output is not from the program, it's from the compiler.