1) Look up the Random class at http://java.sun.com/j2se/1.4.2/docs/api/index.html.
a.
How
many methods are used? ______________________
b.
What is
the difference between nextInt(int ) and nextInt()? ____________________________________________________________________________________________.
2) Using the Random class, what would be the maximum
and minimum values of:
a.
nextInt(6)
+ 5; _____________
b.
nextInt
(1) + 1; _____________
c.
nextInt
(11) + 20; _____________
d.
nextInt
(21) – 10; _____________
3) How would you write the code to produce a random
number between -5 and 5?
import
java.util.Random;
public void getRandom(){
}
4) Describe how a hashmap works.
________________________________________________________________________________________________________.
5) What is information hiding and why is it useful?
________________________________________________________________________________________________________.
6) How do you
initialize an ArrayList? A fixed-size array?
a.
______________________________________________
b.
______________________________________________
7) What is the difference between ArrayList and a
fixed-size Array?
________________________________________________________________________________________________________.
8) Give an example in which it would be better to use
ArrayList.
____________________________________________________
9) Give an example in which it would be better to use
a fixed-size array. ____________________________________________________
10)
Draw a
graphical depiction of the following:
a.
ArrayList
myArray = new ArrayList();
myArray.add(“C201”);
myArray.add(“C202”);
b.
int []
myArray2 =
c.
String[] myArray3 = new String[5];
11)
Write
how to call an external method with the signature ‘public void giveName(String
name)’ from a class called Pet. (You have been provided the first line of code)
Pet dog = new Pet ();
_________________________;