Section 4.14 Assessment: Call a Method of Random
Subgoals for Calling a Method.
-
Write (instance / class) dot method name and ( )
-
Determine whether parameter(s) are appropriate
-
Number of parameters passed must match method declaration
-
Data types of parameters passed must be compatible with method declaration
-
-
Determine what the method will return and where it will be stored
-
Evaluate right hand side of assignment. Value is dependent on method’s purpose
Exercises Exercises
- rand
- nextInt
- nextDouble
- new
- next
- nothing goes here
- 1
- 50
- 49
- int
- double
- Random
- String
2.
Q2: Fill in the blanks for the following code to create a Random number between 1 and 50.
// assume you have declared and initialized variable rand to
// be an instance of the Random class
_______ result = rand._______ ( __________ ) + ___________ ;
D A B C
Fill in blank A.
3.
Q3: Fill in the blanks for the following code to create a Random number between 1 and 50.
// assume you have declared and initialized variable rand to
// be an instance of the Random class
_______ result = rand._______ ( __________ ) + ___________ ;
D A B C
Fill in blank B.
4.
5.
Q5: Fill in the blanks for the following code to create a Random number between 1 and 50.
// assume you have declared and initialized variable rand to
// be an instance of the Random class
_______ result = rand._______ ( __________ ) + ___________ ;
D A B C
Fill in blank D.
You have attempted 1 of 2 activities on this page.