Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects Harnessing the Power of Objects Overload Methods

I do not understand what the task is asking me to do :(

it says: "Create a new method named drive that accepts no arguments. It should call the newer drive method passing in a 1 for the default.

In your new drive method, make sure you call the drive method that takes an int. Pass it a 1, since that's the default"

Sorry I'm new at this and I do not understand what it means when it says "passing in a 1 for the default" could you help me?

class GoKart {
  public static final int MAX_BARS = 8;
  private String color;
  private int barCount;
  private int lapsDriven;

  public GoKart(String color) {
    this.color = color;

  public String getColor() {
    return color;
  public void charge() {
    barCount = MAX_BARS;

  public boolean isBatteryEmpty() {
    return barCount == 0;

  public boolean isFullyCharged() {
    return MAX_BARS == barCount;
public void drive() {
  public void drive(int lapsAmount) {
    barCount -= barAmount;
    lapsDriven += lapsAmount;


1 Answer

Mihailo Jakovljevic
Mihailo Jakovljevic
9,259 Points

What it's asking you to do is basically recreate previous method using the new one. What they mean by passing 1 as default is that your previous method only did one lap, so when you recreate it using your new method you should pass in 1 as parameter. You do this by creating method drive without parameters and inside it call drive and put 1 as parameter. Here is how it should look:

public void drive(int laps) {
  public void drive(){

Hope this helps and best of luck on your java journey :D