Get startedGet started for free

Squaring

Working part-time 5 hours a day, 5 days a week, you often have to remember the square of 5. Rather than putting it everywhere in our code, let's develop a method to make it easier.

This exercise is part of the course

Intermediate Java

View Course

Exercise instructions

  • Give the proper type to return for the custom method.
  • Call that method, saving the result as hours.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

class Squarer {
  // Give this function the proper return type
  static ____ squareOf5() {
    return 5 * 5;
  }

  public static void main(String[] args) {
    // Call the correct function name defined above
    int hours = ____();
    System.out.println("I'm working " + hours + " hours a week");
  }
}
Edit and Run Code