228k views
0 votes
Assume that rand is an object of the Random class.

Which of the following ranges is generated by this statement:
int number = rand.nextInt(1201) + 400; ?
(A) [400..1200]
(B) [400..1201]
(C) [400..1600]
(D) [400..1601]

User SpazDude
by
8.0k points

1 Answer

4 votes

Final answer:

The Java statement 'int number = rand.nextInt(1201) + 400' will generate random numbers in the range of 400 to 1600 inclusive. The correct option is (C) [400..1600].

Step-by-step explanation:

The given Java statement int number = rand.nextInt(1201) + 400 will generate random integers in the range of 400 to 1600 inclusive. The method nextInt(1201) generates numbers from 0 to 1200, and when you add 400 to each of these values, the range adjusts to 400 to 1600. Therefore, the correct option is (C) [400..1600].In Java graphics programming, there is no method drawPixel. Therefore, option A is incorrect. The correct way to draw a single pixel on the screen would be to use the drawLine method with the same starting and ending points. This will draw a line with zero length, which effectively is a single pixel.

User Despertar
by
7.0k points