In: Computer Science
1
Demonstrate the use of local variables in a Java program that
has
1 function
2
Demonstrate the use of overloaded methods
each has three primitive parameters
two methods computes and returns the product to the calling method
for printing
one method computes and prints the product; does not return a
result
3
Demonstrate the use of overloaded constructors
Three constructors each initialize two variables
Three methods, 1 computes the radius of a circle, 1 computes the
area of a rectangle, and area of sphere
1)Local Variables: These are the variables declared inside a
method, we can use those variables inside the method only.
other method even don;t know about those varibles which are
declared in other method... if we try to refer it out of the method
it will shows an error...
Reference:
Output :
2)Method Overloading: Method
overloading means creating multiple methods with same name but
differ in number
of arguments or type of arguments. If we want to return any value
we have to give return type to the method
Reference :
Output :
3)Constructor Overloading: constructors with same names but
differ in number of arguments or type of parameters.
constructor will be automatically called when the object is created
for the class.
Reference :
Output :