Top 10 Most Asked Java Programs in Java Practical Exams

 Top 10 Most Asked Java Programs in Java Practical Exams 

Top 10 Most Asked Java Programs in Java Practical Exams

If you are an IT or Engineering student or doing a java course or you have practical exams then this blog is for you. Here we are getting Top 10 Most Asked Java Programs in Java Practical Exams for you. these are the most asked java programs that is asked almost every practicle exams in BSc(IT).

Here are the list of top 10 most asked Java program during practical exams

1)- Write A Java Program To Accept Name, Age, From The User, and Display.

2)- Write A Java Program That Takes a Number as an Integer and Print the Multiplication up to the Table.   

3)- Write a Java Program to Print The Area and the Parameter of the Circle. 

4)- Write a Java Program to Implement the Fibonacci Series.

5)-  What a Java Program to Calculate Factorial of a Given Number.

6)- Write a Java Program to Display Simple Interest(SI) and Compound Interest(CI).

7)- Write a Java Program to Accept a Number from the User and Check Whether it is Prime or Not.

8)- Write a Java Program to Accept a Number from the User and Display the reverse.

9)- Write a Java Program to Find Greatest of Two Numbers.

10)- Write A Java Program to Accept a charecter from the user whether it is Vowel or Constant.


Solutions -


1)- Write A Java Program To Accept Name, Age, From The User, and Display.


Program:-

import java.util.Scanner;
class user
{
    public static void main(String args[])
    {
        int age; 
        String name;
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter Your Name : ");
        age = scan.nextInt();
        System.out.println("Your Age is : "+ age);
        System.out.println("Enter Your Name :");
        name = scan.next();
        System.out.println("Your Name is :"+ name);
    }
}

2)- Write A Java Program That Takes a Number as an Integer and Print the Multiplication up to the Table.   


Program -


import java.util.Scanner;
class multi
{
    public static void main(String args[])
    {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter The No. :");
        int a = in.nextInt();
        for(int i=1; i<= 10; i++)
        {
             System.out.println("The Multiplication of The Given No.  is:" + a*i);
        }
    }
}

 
3)- Write a Java Program to Print The Area and the Parameter of the Circle. 


Program -

import java.util.Scanner;
class area
{
    public static void main(String args[])
    {
          Scanner scan = new Scanner(System.in);
          System.out.println("Enter Radius :");
          double r = obj.nextDouble();
          double p = 2*math.pi*r;
          double ar = math.pi*r*r;
          System.out.println("Parameter is :"+ P);
          System.out.println("area is :"+ ar);
    }
}


4)- Write a Java Program to Implement the Fibonacci Series.


Program - 

import java.util.Scanner;
class fibo
{
    public static void main(String args[])
    {
        int n, a=0, b=0, c=1;
        Scanner scan =  new Scanner(System.in);
        System.out.println("Enter The n Value :");
        n = scan.nextInt();
        for(i=1; i<=n; i++)
        {
           a = b;
           b = c;
           c = a+b;
           System.out.println("Fibonacci Series is :"+ c);
        }
    }
}


5)-  What a Java Program to Calculate Factorial of a Given Number.


Program- 

import java.util.Scanner;
class factorial
{
    public static void main(String args[])
    {
        int a, b, fact = 1;
        System.out.println("Enter an Integer to Calculate it's Factorial :");
        Scanner scan = new Scanner(System.in);
        a = scan.nextInt();
        if(a<0)
        {
            System.out.println("Number Should Be Positive :");
        }
        else
        {
            for(b=1; b<=a; b++)
            fact = fact*b;
            System.out.println(factor of " + a + " is = " + fact);
        }
    }
}


6)- Write a Java Program to Display Simple Interest(SI) and Compound Interest(CI).

Program-

import java.util.Scanner;
class interest
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        double p, r, t, si, ci;
        System.out.println("Enter The Principle Amount :");
        p= scan.nextDouble();
        System.out.println("Enter The No. of Years :");
        t= scan.nextDouble();
        System.out.println("Enter The Rate of Interest :");
        r= scan.nextDouble();
        si=(p*t*r)/100;
        ci= p*math.pow((1+r/100), t);
        System.out.println("Simple Inerest = " + si);
        System.out.println("compound Inerest = " + ci);
    }
}


7)- Write a Java Program to Accept a Number from the User and Check Whether it is Prime or Not.


Program-


import java.util.Scanner;
class interest
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter The Number :");
        int num  = scan.nextInt();
        int count = 0;
        for(int i = 1; i<=num; i++)
        {
            if(num%i==0)
            {
                count ++;
            }
        }
       if(count == 2)
       {
            System.out.println("It is a Prime Number :");
        }
        else
        {
             System.out.println("It is not a prime number :");
        }

    }
}


8)- Write a Java Program to Accept a Number from the User and Display the reverse.

import java.util.Scanner;
class interest
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter the Number :");
        int num  =  scan.nextInt();
        int rev = 0;
        int sum = 0;
        while(num>0) 130 13
        {
            int r = num%10;
            rev = rev*10+r; 
            sum = sum+r; 
            num =  num/10; 
        }
       System.out.println("Reverse of the number :"+ rev);
    }
}


9)- Write a Java Program to Find Greatest of Two Numbers.

    
Program -

import java.util.Scanner;
class numbers
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter Two Numbers :");
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(a>b)
        {
            System.out.println("a is Greater Number");
         }
        else
            {
                    System.out.println("b is greater number :");
            }
    }
}


10)- Write A Java Program to Accept a charecter from the user whether it is Vowel or Constant.


Program-


mport java.util.Scanner;
class charecters
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter any Charecter :");
        char c= scan.next().charAt(0);
        if(c=='a' || c=='i' || c=='e' || c=='o' || c=='u')
        {
             System.out.println(c+"is a Vowel:");
        }
        else
        {
            System.out.println(c+"is a Constant :");
        }
    }

}



You May Also Read:- 

       

Post a Comment

1 Comments

  1. Great Content. It will useful for knowledge seekers. Keep sharing your knowledge through this kind of article.
    IELTS Writing Skills
    IELTS Writing Techniques

    ReplyDelete