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



Overloading2 Program


Description

This program demonstrates the concept of method overloading.

Associated Concepts:

Method overloading

Algorithm:

There are three overloaded methods in this program.

They have the same name displayLine, but different signatures.

The first method has no parameter.

The second method has one parameter.

The third method has two parameters.

main method:

Call the first displayLine method and pass no argument

Call the second displayLine method and pass only one argument

Call the third computeArea method and pass two arguments

Write two method definitions

The first displayLine method prints the character "*" 10 times.

The second displayLine method prints the passed character parameter 10 times.

The third displayLine method prints the passed character parameter n times, where n is also passed as the parameter.

Source Code



Sample Run



Video