Skip to main content
added 249 characters in body
Source Link
Tom
  • 45.4k
  • 30
  • 142
  • 171

Yes, absolutely.

Its the same thing as doing this

void move(Displaceable b){
    b.move();
}

//somewhere else
move (new Circle(args));

move (new Square(args));

move (new Triangle(args));

If you think about it, its equivalent to have an abstract superclass Figure

public abstract class Figure{
     public abstract move();
}
//Circle extends Figure;

Figure f = new Circle(args);

f.move();

Yes, absolutely.

Its the same thing as doing this

void move(Displaceable b){
    b.move();
}

//somewhere else
move (new Circle(args));

move (new Square(args));

move (new Triangle(args));

Yes, absolutely.

Its the same thing as doing this

void move(Displaceable b){
    b.move();
}

//somewhere else
move (new Circle(args));

move (new Square(args));

move (new Triangle(args));

If you think about it, its equivalent to have an abstract superclass Figure

public abstract class Figure{
     public abstract move();
}
//Circle extends Figure;

Figure f = new Circle(args);

f.move();
Source Link
Tom
  • 45.4k
  • 30
  • 142
  • 171

Yes, absolutely.

Its the same thing as doing this

void move(Displaceable b){
    b.move();
}

//somewhere else
move (new Circle(args));

move (new Square(args));

move (new Triangle(args));