D Create a class Sum with the following fields, constructors and methods: Fields: create two integer fields Constructors: - a no-argument constructor - a constructor with two parameters Methods: - write a getter to return the sum of fields - Create 4 overloaded calculate methods 1. method receives two integer parameters and returns the sum 2. method receives four integer parameters and returns the sum 3. method receives two double parameters and returns the sum 4. method receives two String parameters and returns the sum Create a demo class to test the two constructors, all the methods and display the returned values. You can hard code the parameters values. Make sure the four methods created are toverloaded i.e. same method name for all four.
D
Create a class Sum with the following fields, constructors and methods:
Fields: create two integer fields
Constructors:
- a no-argument constructor
- a constructor with two parameters
Methods:
- write a getter to return the sum of fields
- Create 4 overloaded calculate methods
1. method receives two integer parameters and returns the sum
2. method receives four integer parameters and returns the sum
3. method receives two double parameters and returns the sum
4. method receives two String parameters and returns the sum
Create a demo class to test the two constructors, all the methods and display the returned values. You can hard code the parameters values.
Make sure the four methods created are toverloaded i.e. same method name for all four.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images