Answer:
Yes. Use the nextBoolean() method, described below.
(Or use nextInt(2).)
More Random Methods
Here are some more methods of the Random class:
long nextLong()— Returns the next pseudorandom, uniformly distributedlongvalue from this random number generator's sequence. All possiblelongvalues, both positive and negative, are in the range of values returned.
boolean nextBoolean()
— Returns a pseudorandom, boolean value.
void setSeed(long seed)
— sets the seed of the random number generator.
You might want to do this to repeat a sequence of random numbers in order
to see the effect of some change that you made in a simulation.
There are some other methods of Random not described here.
QUESTION 13:
Think of a really great secret password for your computer account.