COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Methods RightTriangle.java RightTriangleWithLoop.java Geometry.java PayrollWithMethod.java PayrollWithMethodLoop.java Palindrome.java GlobalAndLocal.java Overloading.java Overloading2.java MathMethods.java and MathProgram.java CaesarCipher.java



Overloading Program


Description

This program demonstrates the concept of method overloading.

Associated Concepts:

Method overloading

Algorithm:

There are two overloaded methods in this program.

Both are call computeArea, but they have different signatures.

The first method has one parameter.

The second method has two parameters.

main method:

Call the first computeArea method and pass only one argument

Call the second computeArea method and pass two arguments

Write two method definitions

The first computeArea method returns the circle's area.

The second computeArea method returns the rectangle's area.

Source Code



Sample Run



Video