Skip to main content

If you know that a class can consist of both data and the functions that operate on the data, then an interface is just a list of the functions that a class has to implement.

Take a light switch interface, ILightSwitch ...

public interface ILightSwitch { void TurnOnturnOn(); void TurnOffturnOff(); } 

A class implements an interface if it implements those functions above.

e.g. A LightSwitch class might be

public class LightSwitch implements ILightSwitch { boolean on = false; void TurnOnturnOn() { on = true; } void TurnOffturnOff() { on = false; } } 

The LightSwitch class implements the ILightSwitch interface.

If you know that a class can consist of both data and the functions that operate on the data, then an interface is just a list of the functions that a class has to implement.

Take a light switch interface, ILightSwitch ...

public interface ILightSwitch { void TurnOn(); void TurnOff(); } 

A class implements an interface if it implements those functions above.

e.g. A LightSwitch class might be

public class LightSwitch implements ILightSwitch { boolean on = false; void TurnOn() { on = true; } void TurnOff() { on = false; } } 

The LightSwitch class implements the ILightSwitch interface.

If you know that a class can consist of both data and the functions that operate on the data, then an interface is just a list of the functions that a class has to implement.

Take a light switch interface, ILightSwitch ...

public interface ILightSwitch { void turnOn(); void turnOff(); } 

A class implements an interface if it implements those functions above.

e.g. A LightSwitch class might be

public class LightSwitch implements ILightSwitch { boolean on = false; void turnOn() { on = true; } void turnOff() { on = false; } } 

The LightSwitch class implements the ILightSwitch interface.

If you know that a class can consist of both data and the functions that operate on the data, then an interface is just a list of the functions that a class has to implement.

Take a light switch interface, ILightSwitch ...

public Interfaceinterface ILightSwitch   {   public void TurnOn();   public void TurnOff(); } 

A class implements an interface if it implements those functions above.

e.g. A LightSwitch class might be

public class LightSwitch implements ILightSwitch   { boolean on = false; void TurnOn() { on = true; } void TurnOff() { on = false; } } 

The LightSwitch class implements the ILightSwitch interface.

If you know that a class can consist of both data and the functions that operate on the data, then an interface is just a list of the functions that a class has to implement.

Take a light switch interface, ILightSwitch ...

public Interface ILightSwitch  {   public void TurnOn();   public void TurnOff(); } 

A class implements an interface if it implements those functions above.

e.g. A LightSwitch class might be

public class LightSwitch implements ILightSwitch  { boolean on = false; void TurnOn() { on = true; } void TurnOff() { on = false; } } 

The LightSwitch class implements the ILightSwitch interface.

If you know that a class can consist of both data and the functions that operate on the data, then an interface is just a list of the functions that a class has to implement.

Take a light switch interface, ILightSwitch ...

public interface ILightSwitch { void TurnOn(); void TurnOff(); } 

A class implements an interface if it implements those functions above.

e.g. A LightSwitch class might be

public class LightSwitch implements ILightSwitch { boolean on = false; void TurnOn() { on = true; } void TurnOff() { on = false; } } 

The LightSwitch class implements the ILightSwitch interface.

Source Link
dodgy_coder
  • 13.1k
  • 12
  • 61
  • 70

If you know that a class can consist of both data and the functions that operate on the data, then an interface is just a list of the functions that a class has to implement.

Take a light switch interface, ILightSwitch ...

public Interface ILightSwitch { public void TurnOn(); public void TurnOff(); } 

A class implements an interface if it implements those functions above.

e.g. A LightSwitch class might be

public class LightSwitch implements ILightSwitch { boolean on = false; void TurnOn() { on = true; } void TurnOff() { on = false; } } 

The LightSwitch class implements the ILightSwitch interface.