Hello,
I'm having a bit of trouble with this error. The error seems to be wih setRented but I'm not really sure what to change.
This is my interface

public interface Rentable{
    double getRent();
    void setRent (double rent);
    boolean isRented();
    void setRented (boolean rented);
}

This is my abstract class

public abstract class Vehicle{
    private String make;


    public Vehicle (String make){
        this.make=make;
    }
   public String getMake(){
    return make;
   }

   public abstract String getLicenceCat();

   public String toString(){
    return "Make" + make;
   }
   }

And this is my Concrete subclass

ublic class RentalCar extends Vehicle implements Rentable{
    private String licenceCat;
        private double rent;
    private boolean rented;

    public RentalCar (String make){
        super(make);
    }
    public String getLicenceCat(){
        return "Licence Category";
    }
    public void setRent (double rent){
        this.rent = rent;
        }
        public double getRent(){
            return rent;
        }
    public boolean isRented(){
        rented = true;
        return rented;
    }
    public void setRent (boolean rented){
        this.rented = rented;
    }
    }

Thanks!

Dani AI

Generated

The compiler message means the class still doesn’t implement one (or more) abstract methods declared on a superclass/interface. That usually comes down to an exact-signature mismatch or a simple typo — for example using the wrong method name or parameters, or accidentally typing ublic instead of public. As discovered, a tiny typo can make the compiler think the implementation is missing.

Quick checklist to track these down:

  • Read the compiler error: it shows the exact method signature the class is missing.
  • Compare signatures character-for-character (name, parameter types/order, return type, checked exceptions).
  • Make sure the implementing method is public (interface methods are implicitly public).
  • Add @Override to each method you intend to implement — the compiler will then flag any mismatch immediately (good point from ).
  • Let your IDE generate the method stubs (right-click → implement/override) to avoid manual mistakes.

Small but important behavioral fix: accessors should not change state. For example, isRented() should simply return the flag; it should not set it. A minimal correct pair looks like:

@Override
public boolean isRented() {
    return rented; // no side effects
}

@Override
public void setRented(boolean rented) {
    this.rented = rented;
}

After those fixes, rebuild; if you still see the same error, copy the missing-method signature from the compiler message and search your class for an exact match — that usually reveals the typo.

Recommended Answers

All 2 Replies

Oh dear, was a stupid typo.

It's a good idea to use an @Override annotation whenever overriding an inherited method or implementing an abstract one, eg

@Override
public void setRent (boolean rented){
  this.rented = rented;
}

This will immediatly generate a compiler error telling you exactly what you did wrong (and will be helpful for anyone reading the code).

commented: +1 for Override +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.