Open DavidL0914 opened 1 week ago
Score: 32/40 - Cross review with Joshua Thinh Missed question: 1.Misread question
Integer Division in Java Results in Truncation: When dividing two integers in Java, the result is truncated, meaning only the whole number portion of the quotient is retained, and any fractional part is discarded. For example, 5 / 3 yields 1 because the remainder is ignored. To get a more accurate result, you can use typecasting to convert one or both integers to a double: double result = (double) 5 / 3; // Result: 1.666...
Misread question
Enhanced for Loop in 2D Arrays: When using an enhanced for loop with a 2D array, the loop variable iterates over the elements of the array rather than indices. For example, in for (int[] row : array), row will refer to each sub-array of the 2D array, not a specific row index. Similarly, in for (int val : row), val represents each element of that sub-array. Be mindful that you cannot directly access specific indices using enhanced loops without maintaining additional variables.
.substring(x, y): The .substring(x, y) method in Java extracts a substring from index x (inclusive) to index y (exclusive). For example, "hello".substring(0, 2) results in "he". If x == y, the result is an empty string. Always ensure x and y are valid indices to avoid runtime errors.
n is not initialized to 0, so we need answer.
Keep track of infinite loops. k is never changed in the body of the while loop, it will always be 1 and less than 4, so it causes an infinite loop. For example:
int k = 1;
while (k < 4) {
System.out.println("Infinite loop!");
// k is never updated, so the condition k < 4 is always true
}
Be careful of work
4. C. Value is: 2
21. D. Math.abs (num - val) < minDiff
23. B. ["bear", "zebra", "bass", "cat", "koala", "baboon"]
33. C. 12
39. D. 16
Practice more to be able to finish faster!!
I was spending extra time though to go over work and collaborate with peers, but still should go faster while maintaining accuracy.
Had a deep understanding of all the questions that he got wrong with long explanations of why it was correct. Something he could have done next time is read the questions slower to truly understand the questions.
Reviewing 2014 CB Practice Exam