This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Let me explain in examples.
A && B means when A is false, B does not need to be evaluated as the whole statement is false.
A & B means no matter A is T/F, B will be evaluated.
How about A & B | C? Does it mean A is evaluated, B is evaluated and then C is evaluated?
How about A & B || C ? Does it mean A is evaluated, B is evaluated. If A &B is true, C does not need to be evaluated as the whole statement is true no matter what C is.
If A &B is false, C will be evaluated to see if the whole statement is true or false.
short circuit operators are a way to decide the outcomes of logical AND and OR based on the facts that
1. while ANDing two values ... if first one is false ... the outcome will be false ( no matter what the second value says)
2. while ORing two values ... if first one is true ... the outcome will be true ( no matter what the second value says)
this resolves in a quick test ... and the second value isn't actually required to be computed
Helen Ma wrote:
How about A & B | C? Does it mean ...
How about A & B || C ? Does it mean...
Be careful, when switching between the bitwise and logical operators, with expressions like such -- meaning when they are used in expressions with other operators of different precedence.
The bitwise OR and the logical OR have different precedence. Changing them may change the precedence with other operators in the expression. In this example, it doesn't, but you should always use parens to be safe here.
@Helen Ma : My god !! A splendid explanation once again ..... .They help us a lot . By the way when are you taking the exam of OCPJP ?
Joined: Nov 01, 2011
Thanks. I will take it on 2/24 and I don't expect to pass it. The exam may not be hard, but I expect it to be tricky. I am nervous now. When I get nervous, I may make mistakes.
By the way, do you know if inner and static inner class will be in the exam objective? According to KB, it won't . But yesterday, I checked on Oracle's web site, it is. All I can do is to study Chapter 8 of the book and prepare for it.
Joined: Jan 15, 2012
@Helen Ma : Don't think negatively . Its for sure that the exam would be a tricky one , but you need to be clam and composed . Be confident with what ever you know .
Regarding Inner classes : According to Kathy & Bert , Inner classes are not being directly asked in the exam , but they do check different concepts using inner classes . Its better to be on the safe side by reading Chapter-8 as its a small one.
I am really waiting for 2/24 when you would be taking your exam and would be successful. Would wait for your post in the forum !!