Thursday 13 July 2017

Java(Programs)

                                     PROGRAMS

Here are the list of some important programs which is frequently asked in interview.
These are asked from control statement,oops concept,string,loop etc.

List of important java programs

Prime number

Program:

Let's see the prime number program in java.In this program we take a number to check the number is prime or not.

Class prime{
public static void main(String args[]){
int i,m;
int num=17;//it is the number to be checked
m=num/2;
for(i=2;i<=m;i++){
if(num%2==0)
{
System.out.println("The number is not prime");
}
else
{
System.out.println("The number is prime");
}
break;
}
  }
    }

Output: The number is prime








No comments:

Post a Comment