How can you generate random numbers in java?
Answer / Vikrant Upadhyay
"In Java, the Random class is used to generate random numbers. Here's an example of generating a random number between 1 and 10:
```java
import java.util.Random;
public class Main {
public static void main(String[] args) {
Random rand = new Random();
int randomNum = rand.nextInt(10) + 1; // generates a random number between 1 and 10 (inclusive)
System.out.println(randomNum);
}
}
```
| Is This Answer Correct ? | 0 Yes | 0 No |
public class Base { public void myMethod(int a,intb) {} } // Uses myMethod and then hides it. public class DerivedOne extends Base { private void myMethod(int a,int b); } will this compile or not .yes or no. why
What is a dynamic array java?
What is covariant return type?
What is javac used for?
Why main method is static in java?
What is high level language in computer?
Does constructor return any value?
What is integers and example?
What is the difference between Java and C++?
1 Answers Integreon, TCS, ZS Associates,
What is thread safe singleton?
What is the size of int in 64-bit jvm?
Explain thread in java?