Challenge: Method Overloading
Opgave
Swipe to start coding
Practice Java method overloading by implementing a set of overloaded methods for calculating the area of different shapes.
- Create a public static method named
areathat takes twointparameters representing the width and height of a rectangle, and returns the area as anint. - Create another public static overloaded method named
areathat takes a singledoubleparameter representing the radius of a circle, and returns the area as adouble. - Create a third public static overloaded method named
areathat takes threedoubleparameters representing the sides of a triangle (a,b, andc), and returns the area as adoubleusing Heron's formula.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 3. Kapitel 4
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Suggested prompts:
Can you explain this in simpler terms?
What are some examples related to this topic?
Where can I learn more about this?
Awesome!
Completion rate improved to 8.33
Challenge: Method Overloading
Stryg for at vise menuen
Opgave
Swipe to start coding
Practice Java method overloading by implementing a set of overloaded methods for calculating the area of different shapes.
- Create a public static method named
areathat takes twointparameters representing the width and height of a rectangle, and returns the area as anint. - Create another public static overloaded method named
areathat takes a singledoubleparameter representing the radius of a circle, and returns the area as adouble. - Create a third public static overloaded method named
areathat takes threedoubleparameters representing the sides of a triangle (a,b, andc), and returns the area as adoubleusing Heron's formula.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 3. Kapitel 4
single