Anonymous

Write A Program To Find Area Of Rectangle,triangle,square Using Method Overloading In Java?

4

4 Answers

Monica Stott Profile
Monica Stott answered
This is an example method overloading in Java to write a program to find the area of a rectangle, a triangle and a square.
Class Overload {
double volume(float l, float w, float h) {
return l * w * h;
}

double volume(float l) {
return l * l * l;
}

double volume(float r, float h) {
return 3.1416 * r * r * h;
}
}
public class MethodOverloading {
public static void main(String args[]) {
Overload overload = new Overload();
double rectangleBox = overload.volume(5, 8, 9);
System.out.println("Volume of rectangular box is " + rectangleBox);
System.out.println("");
double cube = overload.volume(5);
System.out.println("Volume of cube is " + cube);
System.out.println("");
double cylinder = overload.volume(6, 12);
System.out.println("Volume of cylinder is " + cylinder);
}
}

This example was submitted to Rose India - a website where you can find many Java scripts and also examples of how to develop Java Scripts.

  • Java Script
Java is a language used to develop webpages. It can be difficult to initially learn as it is like a whole new language and although it is fiddly, many people who have learnt to use it will eventually find it simple. It is important to get the script perfectly correct otherwise it will not be recognized by the computer and cannot be inputted. The smallest mistake such as a comma or a bracket in the wrong location can make a difference and affect the whole script.

Java script is great because it gives us the ability to write any kind of computer program, but the main downside comes from the fact that it is so difficult to learn and create.
Anonymous Profile
Anonymous answered
Find the program to calculate area and perimeter for triangle,circle,square,rectangle using function overloading in c
Anonymous Profile
Anonymous answered
Find the program to calculate area and perimeter for triangle,circle,square,rectangle using function overloading in c
Anonymous Profile
Anonymous answered
Class v
{
int

Answer Question

Anonymous