Discuss a non-static public methods


Discuss teh below:

Q: Create an application named Numbers. The Numbers class should have non-static public methods named sum and difference, each taking a pair of int variables as arguments. As you might expect, the sum method should add the two integers and return the sum; the difference method should find the difference between the two integers and return that value. The main method holds two int variables. Assign values to the variables (you can prompt for these values or hard code them). Instantiate an object from the Numbers class in the main method. Using the two integer variables, use the instantiated object to call the sum and difference methods and print the results. There should be no printing in the methods themselves, only in the main method. Save the application as Numbers.java.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Discuss a non-static public methods
Reference No:- TGS01934615

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)