Page 1 of 1
About Question enthuware.ocpjp.v8.2.1593 :
Posted: Fri Jan 29, 2016 12:11 pm
by pdolezal
Well, just nitpicking

But sometimes Oracle questions are nitpicking too. But: logically the sentence says following implication:
If the above code compiled and run, then it will print (ColoredPoint, Point). Well, the premise of the implication is always false, the conclusion therefore does not matter and the sentence as whole is a tautology. So, strictly according to logic, one should choose
True when evaluating the truth of the sentence

Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Fri Jan 29, 2016 9:21 pm
by admin
I am not sure I agree with what you are saying. The implication that you are drawing i.e.
"If...then... " is not correct. The original sentence says "The above code will print (ColoredPoint, Point) when compiled and run.", so when you try to compile it, it will result in an error, which means it will not print (ColoredPoint, Point). Hence, the statement is false.
Could you please point me to any article that supports your interpretation?
-Paul.
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 8:53 am
by Martyjee
Logic!
I love it
If one abides by the laws of logic, there really is one answer (based on your initial interpretation).
The statement: "The above code will print (ColoredPoint, Point) when compiled and run." has caused some confusion obviously.
Lets transform this sentence into its logical form!
Premise A: The code compiles and runs
Premise B: The code will output '(ColoredPoint, Point)'
I interpret the above sentence as follows to yield the following statement:
Statement 1: A & B: The code compiles and runs AND the code will output '(ColoredPoint, Point)'.
However, pdolezal interpreted it as follows (modus ponens):
Statement 2: A -> B: If the code compiles and runs, it will output '(ColoredPoint, Point)'.
Furthermore, a good Java programmer will notice that statement A turns out to be false (the code does not compile).
Truth table for A & B:
A____B___A & B
true true true
true false false
false true
false
false false
false
Truth table for A -> B:
A___B____A -> B
true true true
true false false
false true
true
false false
true
So based on the initial interpretation of the statement:
In case of statement 1: the statement is false (Paul)
In case of statement 2: the statement is true (pdolezal)
I believe that there is no reason to assume statement 2, because of the paste tense used ("compiled and run"). Implications tend to use the present tense, so I agree with Paul here.
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 9:07 am
by admin
Martyjee, I don't understand how you built the truth table for the second interpretation. What expression are you using for this interpretation and why?
thank you,
Paul.
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 9:33 am
by Martyjee
Hi Paul,
Let me clarify with another example:
Premise A: It rains
Premise B: I go to school by bus
A -> B : If it rains, I go to school by bus ('If A then B' in short)
Lets go back to the truth table:
A: true
B: true
"It rains, I go to school by bus"
This is a valid situation for 'If A then B'
A -> B still holds
A: true
B: false
"It rains, I do NOT go to school by bus"
This can never occur for 'If A then B', because B would have had to be true in that case
A -> B does not hold in this situation
A: false
B: true
"It does NOT rain, I go to school by bus"
Well, A -> B only provides information for the case A that is true, it does not give us any information when A is false. I might go to school by bus, or I might walk! The bottom line is: A -> B doesn't give any clues, so I have to assume A -> B is still valid (true) in this case. I'm not violating A -> B when I go to school by bus when it doesn't rain!
A: false
B: false
"It does NOT rain, I do NOT go to school by bus"
Same reasoning as above: A -> B is not violated!
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 10:50 am
by admin
OK, I am starting to understand what you mean now.
Here are my two separate counter arguments:
1. Your example premises (A: It rains, B: I go to school by bus) are not similar to the ones in question. There are no two independent premises in the question. A. It compiles and run. and B. It will print (ColoredPoint, Point)'. This is not a true representation of the problem statement. Because, it is not possible to print (ColoredPoint, Point) if it does not run. The printing of (ColoredPoint, Point) is completely dependent on the given code compiling. In your example, if it does not rain, it is still possible to go by bus. But if it does not compile, it is not possible to print. Therefore, your third scenario ( A: false B: true ), is not possible.
2. Your claim, " A -> B only provides information for the case A that is true, it does not give us any information when A is false", is correct but that is only because you are ignoring another piece of information given in the problem statement. That is, the code. You are removing a key piece of information that is why you are getting ambiguous interpretations from the remaining part.
By looking at the code, you know that it will not compile. Therefore, you know that it will not print (ColoredPoint, Point). <-- Inference derived by looking at the code. (and not by looking at the statement "If it compiles...").
Now, that you've already derived that it will not print (ColoredPoint, Point), you have to apply this inference to the part, "If it compiles and run, it will print (ColoredPoint, Point). ". Here, you can see that the first part "If it compiles and runs" is inconsequential because you already know that it will not print (ColoredPoint, Point).
Hence, the overall statement, "If it compiles and run, it will print (ColoredPoint, Point). " is false. Irrespective of the code compiles or not, it cannot print (ColoredPoint, Point).
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 10:58 am
by admin
Something that is similar to your example and also similar to the question would be:
"If there is a glass of water, I will drink it.". Is the state, "false, true" possible?
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 11:05 am
by Martyjee
First of all,
Congratulations with your 5000th post!
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 11:46 am
by Martyjee
The logic is based on the statement "if the code compiles and runs, the code will print (ColoredPoint, Point)" and the known fact that the code will not compile.
Of course there is a dependency between A and B, but it is a one-way dependency!
This is not a true representation of the problem statement. Because, it is not possible to print (ColoredPoint, Point) if it does not run.
What you are saying in propositional logic: !A -> !B
That is correct in the
real world, but A -> B (thus the interpretation of pdolezal) does not entail such a statement! (it
does entail !B -> !A though...)
I never said that "if the code compiles and runs, the code will print (ColoredPoint, Point)" was a true representation of the
real world. What we actually need is a
two-way dependency: A <-> B: "
if and only if the code compiles and runs, the code will print (ColoredPoint, Point)".
Truth table
A___B___A <-> B
true true true
true false false
false true
false
false false
true
Now everything is ok and this is a true representation of the real world.
As you can see 'A:false B:true' now yields false (this situation cannot occur when A <-> B)!
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 1:08 pm
by Martyjee
To continue with the story:
A___B___A <-> B
1 true true true
2 true false false
3 false true false
4 false false true
Now, with the added (real world) information you suggested that 3 cannot occur based on premises in the real world (knowing that there is no output if the compilation fails) we can say that only row 4 is left. But then A <-> B is still a true statement! What to do?
Consider the following truth table for A & B:
A___B___A & B
1 true true true
2 true false false
3 false true false
4 false false false
In this truth table, row 4 is the situation we are currently experiencing and it indeed yields false. A & B is in my opinion the right interpretation for all four situations:
"The code compiles and runs AND the code will output '(ColoredPoint, Point)".
Summary:
The original sentence:
"The above code will print (ColoredPoint, Point) when compiled and run."
This statement is always true based on the information given when interpreted as A -> B or A <-> B.
It is false (what the quiz designers intended!) when interpreted as A & B, which is in my opinion the right interpretation!
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 9:39 pm
by admin
Martyjee wrote:First of all,
Congratulations with your 5000th post!
Thank you

Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Thu Feb 04, 2016 9:41 pm
by admin
Martyjee wrote:To continue with the story:
A___B___A <-> B
1 true true true
2 true false false
3 false true false
4 false false true
Now, with the added (real world) information you suggested that 3 cannot occur based on premises in the real world (knowing that there is no output if the compilation fails) we can say that only row 4 is left. But then A <-> B is still a true statement! What to do?
Consider the following truth table for A & B:
A___B___A & B
1 true true true
2 true false false
3 false true false
4 false false false
In this truth table, row 4 is the situation we are currently experiencing and it indeed yields false. A & B is in my opinion the right interpretation for all four situations:
"The code compiles and runs AND the code will output '(ColoredPoint, Point)".
Summary:
The original sentence:
"The above code will print (ColoredPoint, Point) when compiled and run."
This statement is always true based on the information given when interpreted as A -> B or A <-> B.
It is false (what the quiz designers intended!) when interpreted as A & B, which is in my opinion the right interpretation!
Thank you for sharing your thoughts. I understand it now.
-Paul.
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Tue Feb 09, 2016 10:36 am
by pdolezal
I see that meanwhile my post resulted in quite a discussion and Martyjee came with a nice summary.
Yes, it is the matter of interpretation… and when in
logic mode

using implications (i.e., A → B) seems natural to me, although it is not very common in the real world. Anyway, I admit it is a bit difficult then to me, because when doing an exam, where using logic is assumed, I tend to think rather in such implications and as not being a native English speaker, I tend to interpret
if and
when conjunctions as implications.
By the way, just a while ago I encountered another question that is quite similar (it's
enthuware.ocpjp.v8.2.1089):
Expression (s instanceof java.util.Date) will return false if 's' was declared as a variable of class java.lang.String.
The answer is
False and the explanation is:
It will not even compile because the compiler knows that 's' (which is declared as of class String) can NEVER refer to an object of class java.util.Date. So, it will not accept this code.
Had 's' been declared as a variable of type Object, this code would have compiled because compiler sees that at run time it is possible for s to refer to an object of class Date.
Here, however, both interpretations – implication and conjunction – leads to the same answer, which is probably a bit better situation, although does not help me much to understand which way and when the test designers use. I feel somewhat stupid when knowing the answer, but being unsure which choice to take, because I'm uncertain about their meanings
Anyway, thank you for the discussion!
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Tue Feb 09, 2016 11:09 am
by admin
I do not think you should worry about this issue arising in the real exam because the real exam does not have true/false type questions. In our effort to formulate questions from multiple angles based on the same concept, some times (as in this case) a question may turn out to be a bit ambiguous inadvertently. We will improve such questions.
HTH,
Paul.
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Tue Feb 09, 2016 11:10 am
by Martyjee
Let's break down this new example:
Premise A: 's' is declared as String
Premise B: Expression returns Date.
A____B____A -> B
1)true true true
2)true false false
3)false true true
4)false false true
Actually, in this example we know that A is true (based on the assumption that 's' was declared as String). However, when run, the Expression does not return Date (because we get a compiler error). So we are in situation 2 and A -> B is (indeed) false!
So in my opinion this example makes it clear that an implication is intended and therefore the example is not similar to the one in the preceding discussion...
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Tue Feb 09, 2016 11:31 am
by Martyjee
Anyway, I admit it is a bit difficult then to me, because when doing an exam, where using logic is assumed, I tend to think rather in such implications and as not being a native English speaker, I tend to interpret if and when conjunctions as implications.
Yes, that can indeed be tricky.
I took the exam last year and (luckily) I did not encounter any questions that could lead to such confusion

Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Fri Nov 15, 2019 9:29 am
by timwaagh
how is the specificity of a method evaluated? does it use a points system like css or some other rule or should we make an intuitive guess?
Re: About Question enthuware.ocpjp.v8.2.1593 :
Posted: Fri Nov 15, 2019 10:07 pm
by admin
Exact details are given in
15.12. Method Invocation Expressions of Java Language Specification 11.
But it is a lot more complicated than required for the exam. For a simplified (but less accurate) version, you should check out this topic from a certification book.