Things I looked up!

  • Question 9: I wasn’t exactly sure on this one. Initially I thought it would just be (int)(Math.random()6) + (int)(Math.random()6) but then I talked to aiden and realized that we might have to add 2 if it only floors the numbers, since we would be getting a random number from 0 to 5 rather than 1 to 6. I then tested it below to figure out that it always rounds down, so we do have to add 2.
  • Question 10: we knew the answer to this question, but this sparked a discussion about the difference between a class and an interface. We learned that multiple interfaces can be implemented by a single class while only one class can be extended, and the interfaces only contain static variables and abstract methods.
  • Question 18: I wasn’t sure how order of operations works so I tested it myself below. Turns out the question was actually about integer rounding, I didn’t even think of it but by first dividing 404/10, we would actually get 40 not 404. This is because 404 and 10 are integers so our answer should be an integer value.
  • Question 22: We weren’t sure about this one at first either, but we realized that we missed the fact that E doesn’t work since it goes the wrong way, iterating through the rows first before the columns meaning it would give 142536 instead of 123456.
double RandNum = Math.random()*6;
System.out.println(RandNum);
System.out.println((int)(RandNum));
5.933112228312195
5
System.out.println(404 / 10 * 10 + 1);
401

Corrections

  • Question 19: I missed part of this question that x is incremented by 2 rather than 1, this means that the numbers will always be odd.
  • Question 39: I didn’t know that the Set method returns the value that was at the index before the change, so I thought that the code would not work correctly.