What is wrong, logically, with the following code?
Give this one a try later!
There is no logical error, but there is no need to have (x <= 10) in the second
conditional or (x <= 6) in the third conditional
, What is the output of the following code:
int num1 = 6;
int num2 = 10;
num1 = num1 + num2;
num2 = num1 + num2;
System.out.println(num1 + ", " + num2);
Give this one a try later!
16, 26
Write code to declare and instantiate an object of the Random class (call the
object reference variable rand). Then write a list of expressions using the
nextInt method that generate random numbers in the following specified
ranges, including the endpoints. Use the version of the nextInt method that
accepts a single integer parameter.
a. 0 to 10
b. 0 to 400
c. 1 to 10
d. 1 to 400
e. 25 to 50
f. -10 to 15
Give this one a try later!
a.
0 to 10
rand.nextInt(11)
b.
0 to 400
rand.nextInt(401)
c.
1 to 10
rand.nextInt(10) + 1
Give this one a try later!
There is no logical error, but there is no need to have (x <= 10) in the second
conditional or (x <= 6) in the third conditional
, What is the output of the following code:
int num1 = 6;
int num2 = 10;
num1 = num1 + num2;
num2 = num1 + num2;
System.out.println(num1 + ", " + num2);
Give this one a try later!
16, 26
Write code to declare and instantiate an object of the Random class (call the
object reference variable rand). Then write a list of expressions using the
nextInt method that generate random numbers in the following specified
ranges, including the endpoints. Use the version of the nextInt method that
accepts a single integer parameter.
a. 0 to 10
b. 0 to 400
c. 1 to 10
d. 1 to 400
e. 25 to 50
f. -10 to 15
Give this one a try later!
a.
0 to 10
rand.nextInt(11)
b.
0 to 400
rand.nextInt(401)
c.
1 to 10
rand.nextInt(10) + 1