• Print Hello World
public class Test{
public static void main(String args[]){
System.out.println("hello World");
}
}
• Get Input from User
import java.util.*;
public class Test {
public static void main(String[] args) {
int i;
Scanner sc=new Scanner(System.in);
System.out.println("enter the number ");
i=sc.nextInt();
System.out.println("num is "+i);
}
}
• Print Integer
import java.util.*;
public class Test {
public static void main(String[] args) {
int i=100;
System.out.println("num is "+i);
}
}
• Add two Numbers
import java.util.*;
public class Test {
public static void main(String[] args) {
int a,b,c;
Scanner sc=new Scanner(System.in);
System.out.println("enter the value of a ");
a=sc.nextInt();
System.out.println("enter the value of b ");
b=sc.nextInt();
c=a+b;
System.out.println("the addition is "+c);
}
}
• Check Even or Odd
import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int num;
System.out.println("enter the number ");
num=sc.nextInt();
if(num%2==0){
System.out.println(num+" is even");
}
else
{
System.out.println(num+" is odd");
}
}
}
• Check Prime or Not
import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int num;
boolean b=true;
System.out.println("enter the number ");
num=sc.nextInt();
for(int i=2;i='a' && ch<='z' || ch>='A' && ch<='Z'){
System.out.println("Alphabet ");
}else{
System.out.println("Number");
}
}
}
• Check Vowel or Not
import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
char ch;
System.out.println("Enter some Alphabet");
ch=sc.next().charAt(0);
switch(ch){
case 'a':
case 'A':
case 'E':
case 'e':
case 'O':
case 'o':
case 'i':
case 'I':
case 'U':
case 'u':
System.out.println("Vowel ");
break;
default:
System.out.println("not a vowel ");
}
}
}
• Check Leap Year or Not
• Check Reverse equal Original
• Add Subtract Multiply Divide
• Make Calculator
• Add Digits of Number
• Calculate Average Percentage
• Calculate Arithmetic Mean
• Calculate Student Grade
• Print Table of Number
• Print Prime Numbers
• Add n Numbers
• Interchange two Numbers
• Reverse Numbers
• Swap two Numbers
• Count Positive Negative Zero
• Find Largest of two Numbers
• Find Largest of three Numbers
• Find Factorial of Number
• Find HCF LCM
• Calculate Area Perimeter
• Calculate Area Circumference
• Fahrenheit to Centigrade Conversion
• Centigrade to Fahrenheit Conversion
• Print ASCII Values
• Print Fibonacci Series
• Check Palindrome or Not
• Check Armstrong or Not
• Generate Armstrong Numbers
• Find ncR nPr
• Decimal to Binary Conversion
• Decimal to Octal Conversion
• Decimal to Hexadecimal Conversion
• Binary to Decimal Conversion
• Binary to Octal Conversion
• Binary to Hexadecimal Conversion
• Octal to Decimal Conversion
• Octal to Binary Conversion
• Octal to Hexadecimal Conversion
• Hexadecimal to Decimal Conversion
• Hexadecimal to Binary Conversion
• Hexadecimal to Octal Conversion
• Pattern Programs
• Print Diamond Pattern
• Print Floyd Triangle
• Print Pascal Triangle
• One-Dimensional Array Program
• Linear Search
• Binary Search
• Add two Numbers using Pointers
• Find Largest Element in Array
• Find Smallest Element in Array
• Reverse Array
• Insert Element in Array
• Delete Element from Array
• Merge two Array
• Bubble Sort
• Selection Sort
• Insertion Sort
• Two-Dimensional Array Program
• Add two Matrices
• Subtract two Matrices
• Transpose Matrix
• Multiply two Matrices
• Three-Dimensional Array Program
• Print String
• Find length of String
• Compare two String
• Copy String
• Concatenate String
• Reverse String
• Delete Vowels from String
• Delete Words from Sentence
• Count Character in String
• Count Word in Sentence
• Remove Spaces from String
• Sort a String
• Uppercase to Lowercase Conversion
• Lowercase to Uppercase Conversion
• Swap two Strings
• Check Anagram or Not
• Generate Random Numbers
• Read File
• Write to File
• Read & Display File Content
• Copy File
• Merge two File
• List files in Directory
• Delete File
call by reference
ReplyDeletecall by value
Nice List of Questions Java Insertion Sort Algorithm .
ReplyDeletethanks