Here is a list of what I had gotten wrong on an exam:
boolan a = false, b = true, c = true, d = false, e = true;
1. System.out.println a != c;
I had converted it to a==c, and had answered FALSE. I'm checking the answer again -- and since a = false, c = true; the result of a == c would be FALSE. FALSE was my answer.
But I got the answer wrong, did I read too much into it and convert the not equals into ==, when I should've left it alone, and resulting in a != c being TRUE. because that would be true, a(false) doesn't equal c(true.
2. This was a question that asked for showing the EXACT output that will be created by execution of the following program.
package javaapplication1; public class JavaApplication1 { public static void main (String[] args) { int manny = 40, moe = 23, jack = 26; System.out.printf ("%3d%3d%3d\n", manny, moe, ++jack); if (manny > moe) if (moe > jack) { moe = 40; System.out.printf ("%3d%3d\n", ++jack, moe--); } else manny-=manny; else if(moe > jack) jack = 50; else System.out.printf ("%3d%3d\n", ++jack, moe--); System.out.printf("%3d%3d%3d\n", manny, moe, ++jack); if (manny > moe) if (moe > jack) { moe = 31; System.out.printf("%3d%3d\n", ++jack, moe--); } else manny -= manny; else if(moe > jack) jack = 50; else System.out.printf ("%3d%3d\n", ++jack, moe--); System.out.printf("%3d%3d%3d\n", manny, moe, ++jack); } }
Here is how I tracked my variables, I would cross them out as I read through the program and the most bottom one would be the newest value
manny moe jack
40 23 26
0 22 27
28
29
My output looked like this(everything had to be exact, spacing is indicated by the underscore _ )
OUTPUT
_40_23_27
_28_23
__0_22_29
Please help me learn what I did wrong.