A class is a template from which objects are created. A class declaration typically contains a set of attributes (instance variables) and functions (methods).
10.2 | Methods
In Java, functions, and procedures are called methods. Methods can include zero or more input parameters and zero or one return parameter. The following code shows some method declarations. An arithmetic class has two methods printSum and getSum. method printSum has two input parameters both of integer type and no return parameter. while method getSum has two integer type input parameters and one integer type return parameter.
10.2.1 | Method Overloading
In Java, method overloading occurs when two or more methods in the same class have the same name but different parameters. Two methods can be considered overloaded if any of the below conditions are true:
- The number of parameters is different for the methods.
- The parameter types (input or return) are different.