cbquiz2

Corrections & Tricky Questions

Question 10

String str = "0";

str += str + 0 + 8;

System.out.println(str); //output: 0008

str + int assume int are also strings because the string come first

str + int + int + int

Question 12

.set() return the orginal string

q12

Question 13

art is between two words, so each individual word doesn't have "art" in it which should return false

Question 25

.add(#, x) add x to the index number and the value that was orginally on that spot was pushed back by 1

.remove(k) - would return k

list - fixed -> the reason why "baboon" disappeared

However, after baboon is moved to index 1, the loop doesn't end. It will continued to check till it reaches baboon again, and it will be moved to the end.

Question 31

for (int[] j : arr) //[] is needed because it's a 2d array

Question 40

I. doesn't not work because for each loop -> delete name - not effect on nameList

II. doesn't work because it will skip a few names since removing names causes size to decrease while k is still increasing

III. works because it starts from the end so it won't effect the names in the front