0% found this document useful (0 votes)
17 views

Class Addtwonumbers //class Declaration (

This Java program defines a class called AddTwoNumbers with a main method that declares three integer variables x, y, z. It assigns values of 10 to x and 20 to y, adds those values and assigns the sum to z, then outputs to the screen "Sum of x and y = " followed by the value stored in z.

Uploaded by

vvsprasad
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Class Addtwonumbers //class Declaration (

This Java program defines a class called AddTwoNumbers with a main method that declares three integer variables x, y, z. It assigns values of 10 to x and 20 to y, adds those values and assigns the sum to z, then outputs to the screen "Sum of x and y = " followed by the value stored in z.

Uploaded by

vvsprasad
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

class AddTwoNumbers

//Class Declaration

public static void main(String args[]) //Main Function


{
int x, y, z;
// Variable Declaration
x = 10;
//Assigning 10 to the variable x.
y = 20;
//Assigning 20 to the variable y.
z = x + y;
//Expression to Add two variables x, y and save the result to z
System.out.println("Sum of x and y = "+z); //This line output the value of z on the Screen
}
}

You might also like