Write a method called randomInRange that takes in two numbers representing a range. Print an error message and return zero if the second parameter is less than the first. Otherwise, the method should return a randomly generated integer in that range (inclusive). You may assume that the class has a static Random object called generator already declared and instantiated.

What will be an ideal response?

```
public int randomInRange(int a, int b) {
if(b < a) {
System.out.println("Error, invalid range!");
return 0;
}
return generator.nextInt(b – a + 1) + a;
}
```

Computer Science & Information Technology

You might also like to view...

How do you use the FLVPlayback 2.5 component?

What will be an ideal response?

Computer Science & Information Technology

Joe a website administrator believes he owns the intellectual property for a company invention and has been replacing image files on the company's public facing website in the DMZ. Joe is using steganography to hide stolen data.Which of the following controls can be implemented to mitigate this type of inside threat?

A. Digital signatures B. File integrity monitoring C. Access controls D. Change management E. Stateful inspection firewall

Computer Science & Information Technology