program ——->

class Overload
{
int volume (int x) // volume of cube
{
return (x*x*x);
}
double volume(double r, int h) // volume
//cylinder
{
return (3.14519F*r*r*h);

}

long volume(long 1, int b, int h) // volume of // rectangular

{ return (l*b*h);
}
}
class Overload Demo2
{
public static void main(String args[])
{
Overload v=new Overload();
System.out.println(“Volume of a cube = “+v.volume(10));
System.out.println(“Volume of a cylinder = “+v.volume(2.5,8));
System.out.println(“Volume of a Rectangle = “+v.volume(100L,75,15));
}
}

output —–>

D:\jaava>javac Rational. java

D:\jaava>java ObjectAsParameter

2/5 + 3/7 = 29/35

D:\jaava>

AIM: To demonstrate the Method Overloading

Name of the Experiment:

Write a java Program for to demonstrate Method Overloading – Find Volume of cube, cylinder and rectangle.

HW/SW requirements:

Processor

AMD Athelon TM 1.67 GH,

RAM

: 256 MB

Hard Disk

: 40 GB

JDK is required, with compilers, notepad

Algorithm:

  1. Start the program.
  2. Declare the class overload with variables and load the values.
  3. Define the methods, Overload the methods volume by using type of argument.
  4. End of a class.
  5. Start of main class
  6. Define the main method and create the multiple objects.
  7. Call the method volume on the basis of passing argument.
  8. End of main class.
  9. Compile the program.
  10. Run the Class file and pass the Input see the output.
  11. Stop the process.
  • Related Posts

    Acer Aspire Lite AMD

    Acer Aspire Lite AMD Ryzen 5 5500U Premium Thin and Light Laptop (16 GB RAM/512 GB SSD/Windows 11 Home) AL15-41, 39.62 cm (15.6″) Full HD Display, Metal Body, Steel Gray,…

    Lenovo ThinkPad (Refurbished) | Buy At Best Laptop 2024

    (Refurbished) Lenovo ThinkPad 7th Gen Intel Core i5 Thin & Light HD Laptop (8 GB DDR4 RAM/256 GB SSD/14″ (35.6 cm) HD/Windows 11/MS Office/WiFi/Webcam/Intel Graphics) Lenovo ThinkPad (Refurbished) Product information…

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You Missed Products

    • October 19, 2024

    Acer Aspire Lite AMD

    • July 8, 2024
    Acer Aspire Lite AMD

    Lenovo ThinkPad (Refurbished) | Buy At Best Laptop 2024

    • July 8, 2024
    Lenovo ThinkPad (Refurbished) | Buy At Best Laptop 2024

    Lenovo ThinkPad 8th Gen Intel Core i5: A Thin & Light HD Laptop for Seamless Performance

    • July 6, 2024
    Lenovo ThinkPad 8th Gen Intel Core i5: A Thin & Light HD Laptop for Seamless Performance