This section contains 329 words (approx. 2 pages at 300 words per page) |
A method is fundamentally a function, a self-contained block of code that performs some action and returns a value. It is identical in all respects to a normal function except that a method always belongs to an object or class. C++ supports conventional functions and methods, but in Java every function is a method.
Methods can be declared with the visibility modifiers "private," "protected," or "public," and these determine what methods other program entities can invoke on the object. The behavior of an object is fully defined by all the methods it supports; but the interface to an object is defined only by the public methods it supports because this will determine how the object appears to other program entities.
When a method on an object is invoked it is often described as "sending a message to the object." This can be confusing terminology to programmers new to...
This section contains 329 words (approx. 2 pages at 300 words per page) |