

Moderator: admin
What you are saying in propositional logic: !A -> !BThis is not a true representation of the problem statement. Because, it is not possible to print (ColoredPoint, Point) if it does not run.
Thank youMartyjee wrote:First of all,
Congratulations with your 5000th post!
Thank you for sharing your thoughts. I understand it now.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!
The answer is False and the explanation is:Expression (s instanceof java.util.Date) will return false if 's' was declared as a variable of class java.lang.String.
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 meaningsIt 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.
Yes, that can indeed be tricky.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.
Users browsing this forum: Bing [Bot] and 11 guests