CORRECTIONS:

MY ANSWER: I AND II ONLY


CORRECT ANSWER: II ONLY


JUSTIFICATION: I thought that Choice 1 wouldn’t return the correct value - I thought that if there was only one element it would result in an error when doing array length - 1 = 0. However, I was wrong in my judgement because it would return the correct value.



MY ANSWER: for (int k = 1); k <= 100; k++) System.out.println(k % 4);


CORRECT ANSWER: for (int k = 4); k <=100; k = k + 4) System.out.println(k);


JUSTIFICATION: I was under the impression that since the sample code segment improved in increments by the next value in the list of numbers, we should have the answer do that as well - however, since the initial code segment is checking for numbers that are exactly divisible by 4, I should have gone by increments k = k + 4 in the answer instead of k++.



MY ANSWER: 7, 9, 11


CORRECT ANSWER: 8, 9, 11


JUSTIFICATION: 7 would not work, since y would then be equal to 1. This wouldn’t work out, since none of the answers in this option would test out the conditions in the program for if x was even.



**MY ANSWER: (y > 10000) && (x > 1000   x < 1500)**


**CORRECT ANSWER: (y > 10000   x > 1000) && (y > 10000   x < 1500)**


JUSTIFICATION: The expression I put would evaluate to false regardless of x was in the right range. Option ‘A’ would not do this and would be equivalent to the above expression.




THINGS I HAD TO LOOK UP:

For some of the questions I was not sure what the example code was outputting so I would put it in a Java compiler and try to understand the output. Otherwise, I mostly tried to do things on my own.