It is a sample Java program try to explain each command line
Solution
Import Java.util.Scanner
Imports java library for scanning the input from STDIN
public class FirstProgram
Defines a class FirstProgram which is visible across all the assemblies.
No it should be
public static void main(String[] args)
System.out.println(“Hello out there!”)
Prints Hello out there! to the console.
System.out.print(“I will add two numbers for you.”)
Prints I will add two numbers for you. to the console.
int n1,n2 //Declares two integer variables naming n1 and n2
Scanner k = new Scanner(System.in);
//Declares and Defines a Scanner variable named k which will help us to take input from Console.
System.out.print(“Enter first integer value : ”)
Prints Enter first integer value : to the console.
n1 = k.nextInt()
//Get next integer from the Console and assign it to n1
System.out.print(“Enter second integer value : ”)
Prints Enter second integer value : to the console.
n2 = k.nextInt()
//Get next integer from the Console and assign it to n2
int s = n1+n2;
//Adds n1 and n2 and assign it to s
System.out.print(“Two entered # are: “+n1+”,” + n2+”\ The sum is: ”);
Prints Two entered # are 3,17
The sum is:
System.out.print(n1+n2);
Prints 20
System.out.print(“\ The sum is = ”+s);
Prints The sum is = 20

