Originally posted by Bert Bates:
Sam -
For instance, I think Dan's questions on operator precedence are great for general Java knowledge (although personally I'm a big fan of parenthesis ) , but these precedence questions are much, much more difficult than anything you will experience on the actual exam.
I took the real exam in late November and found it to be very easy relative to my exam. In response, I reorganized my exam such that many of the questions have been removed from the comprehensive exams and are now only found in single topic exams marked "Optional". For example, many of the questions related to operator precedence are now found only in the "Optional" sections. The questions that remain in the non-optional exams require only a very minimal understanding of operator precedence. For example, a person is required to know that multiplication and division have higher precedence than addition and subtraction. Those are precedence rules that we learn in elementary school while we are learning basic arithmetic so I think it is fair game on any certification exam that includes the use of basic arithmetic.
Anyone that learns the basics of boolean logic knows that the "and" operator has higher precedence than the "or" operator. Therefore, I think that understanding the precedence rules of boolean logic is fair game for any exam that includes the use of boolean logic.
Of course, the real exam requires a person to know the precedence of the postfix, prefix, and cast operators and a trick question involving the precedence of the cast operator is almost sure to appear on the real exam. That would be the question where the cast operator appears to explicitly narrow the result of an entire expression but really only narrows the first operand in the expression.
From the feedback that I have received it appears that the above precedence rules are not difficult to master. Instead, people seem to have more difficulty understanding that Java parses expressions from left to right while humans evaluate expressions starting from the inner most parenthesis. The difference between the two algorithms is not apparent unless the expression contains postfix and/or prefix operators.
In summary, the non-optional sections of my exam require an understanding of those rules of arithmetic that we all learned in elementary school and an understanding of boolean logic. Of course, like the real exam, it is also necessary to know the precedence of the postfix, prefix, and cast operators. That's the easy part.
The more difficult concept to master is the fact that Java parses expressions from left to right while we humans start with the inner most parenthesis. As a result, the order in which Java evaluates the prefix and postfix operators is always left to right while we humans would prefer to first increment those operands that appear within the inner most parenthesis.
An easy algorithm to remember is the one described by Maha Anna. You should first go through the expression from left to right and evaluate all of the postfix and prefix increment/decrement expressions. Then use a second pass through the expression to evaluate all of the other operators based on the operator precedence rules and based on the use of parenthesis. Of course, Java does not really use two passes, but we humans have an easier time with the two pass approach.
Once again, the December 4 version of my exam has been reorganized such that difficult questions appear in sections marked "Optional". If you are still having trouble with the operator questions in the non-optional sections of the December 4 exam, then you really need to do more work with operators.