Subsection2.4.1Subgoals for using objects (creating instances)
Declare variable of appropriate class datatype.
Assign to variable: keyword new, followed by class name, followed by ().
Determine whether parameter(s) are appropriate (API)
Number of parameters
Data types of the parameters
Subsection2.4.2ObjUse-WE2-P1
ExercisesExercises
1.
CClick on the variables (object references) in the following code
/* creates new random object with default seed */:
Random: rand: = new Random();:
/* creates new random object with seed parameter */:
Random: rand2: = new Random(1234567890);:
2.
Click on the class names (but not constructors) in the following code
/* creates new random object with default seed */:
Random: rand: = new Random();:
/* creates new random object with seed parameter */:
Random: rand2: = new Random(1234567890);:
3.
Click on the calls to the Random constructor in the following code
/* creates new random object with default seed */:
Random: rand: = new Random();:
/* creates new random object with seed parameter */:
Random: rand2: = new Random(1234567890);:
4.
Click on the parameters which are passed to the Random constructor in the following code
/* creates new random object with default seed */:
Random: rand: = new Random();:
/* creates new random object with seed parameter */:
Random: rand2: = new Random:(1234567890:);