Solved

Consider the Following Snippet of Code: Random Generator = New

Question 27

Multiple Choice

Consider the following snippet of code: Random generator = new Random() ;
Int randNum = generator.nextInt(20) + 1;
Which of the following will be true after these lines are executed?


A) randNum will hold a number between 1 and 20 inclusive.
B) randNum will hold a number between 0 and 20 inclusive.
C) randNum will hold a number between 1 and 21 inclusive.
D) these lines will not be executed because a compiler error will result.
E) none of the above

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions