Interface Explained

The buttons on the front of your television set are the interface between you and the electrical wiring on the other side of its plastic casing.

You press the „power“ button to toggle the television on and off.

In this example, your particular television is the instance, each method is represented by a button, and all the buttons together comprise the interface.

(Other television sets that are the same model as yours would have the same interface.)

In its most common form, an interface is a specification of a group of related methods without any associated implementation of the methods.

A television set also has a myriad of attributes, such as size and whether it supports color, which together comprise its structure. A class represents the full description of a television, including its attributes (structure) and buttons (interface).

Getting the total number of televisions manufactured could be a static method of the television class. This method is clearly associated with the class, yet is outside the domain of each individual instance of the class. Another example would be a static method that finds a particular instance out of the set of all television objects.

Member accessibility

„Private member“ redirects here. For other uses, see Private members club.
Further information: Information hiding

The following is a common set of access specifiers:[10]

  • private (or class-private) restricts the access to the class itself. Only methods that are part of the same class can access private members.
  • protected (or class-protected) allows the class itself and all its subclasses to access the member.
  • public means that any code can access the member by its name.

source: http://en.wikipedia.org/wiki/Class_(computer_programming)

admin