Thursday Review Quiz
Take this quiz to review yesterday's material. The quiz is
open-book, open-note and open-neighbor (feel free to work
together)!
For the questions that involve coding, you can just write your
answers on a piece of paper -- you don't need to type them into
the computer, compile and run them (unless you really want to).
-
Write a program fragment that intializes an array of
100 integers to random values between 0 and 100. Hint -
for help on generating random numbers, look in the
java.util.Random class in the Java Docs.
-
Repeat the above question, but use an ArrayList instead
of a simple array.
-
Discuss the performance differences between the java.util.ArrayList
and java.util.LinkedList classes.
-
Write a class that implements the java.awt.event.MouseListener
interface with empty methods. Don't worry too much about what
this interface does, just make sure that your class is syntactically
correct.
-
Optional Bonus Question Suppose you
wanted to let programs determine whether two PartTime
objects (from your lab) represent the same person. What would
be the "preferred Java" way to do this? Hint: Think about
how to check Strings to see if they have the same characters.
Write a sample implementation.