overriden methods provide one interface multiple methods.
what is meant by one interface multiple methods

Edited by __avd: Remove [B] [I] tags.

8 Years
Discussion Span
Last Post by verruckt24

From Wiki,

Method overriding, in object oriented programming, is a language feature that allows a subclass to provide a specific implementation of a method that is already provided by one of its superclasses. The implementation in the subclass overrides (replaces) the implementation in the superclass.


sir my doubt is not about over riding ?
what is meant by
one interface multiple methods ?


The question seems ambiguous to me.
Any Java interface can contain many methods.
What this more probably refers to is illustrated in this example:
You have an interface Vehicle that declares a void drive(int speed) method.
class Car implements Vehicle {
void drive.... etc
so does
class Speedboat implements Vehicle {
void drive(...
Now you have one interface, two versions of the method. You can simply call the method, and the appropriate implementatoin is used:
Vehicle v = (something...)
v.drive(30); // calls Car's drive or Speedboat's drive depending on what kind of Vehicle this is.

Edited by JamesCherrill: n/a


I suppose here, the word interface doesn't mean the Java language type. What it wants to mean is a contract, much like how it is between a library developer and it's user. The word here maps more closely to the method signature. Something like "overidding allows multiple methods to have the exact same signature" so "one interface, multiple methods"

PS: On reading JC's post again, I guess he's trying to say the same thing.

Edited by verruckt24: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.