What is prime number in java?



What is prime number in java?..

Answer / Rudra Pratap Singh

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. To check if a number is prime, you can use the following code snippet: boolean isPrime = n > 1 && (n % 2 != 0 || n == 2) && (for i=3 to sqrt(n)) (n % i != 0).

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is a char in java?

1 Answers  


What are the various access specifiers in java?

1 Answers  


What is the point of java?

1 Answers  


how to identify duplicate values in arraylist

2 Answers   TCS,


Explain a few methods of overloading best practices in java?

1 Answers  


What is Gang of four design patterns

1 Answers   Infosys,


Can java object be locked down for exclusive use by a given thread?

1 Answers  


Where is the find and replace?

1 Answers  


What are different type of access modifiers?

3 Answers  


Is string a keyword in java?

1 Answers  


How can you debug the Java code?

6 Answers   BirlaSoft,


Can we call the constructor of a class more than once for an object?

1 Answers  


Categories