1. Write a Java program to find maximum between two numbers.
Solution :-
Static
class max2
{
public static void main(String args[])
{
int no1=10,no2=20,max;
if(no1 > no2)
{
System.out.println("First number is Big :- "+no1);
}
else
{
System.out.println("Second number is Big :- "+no2);
}
}
}
Output :-
Dynamic
import java.util.*;
class max2
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the First number :- ");
int no1 = in.nextInt();
System.out.println("Enter the Second number :- ");
int no2 = in.nextInt();
if(no1 > no2)
{
System.out.println("First number is Big :- "+no1);
}
else
{
System.out.println("Second number is Big :- "+no2);
}
}
}
Output :-