Difference between revisions of "Method (computer programming)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Created page with "In object-oriented programming (OOP), a '''method''' (or '''message''') is a procedure (see Subroutine) associated with an object. == De...")
 
Line 7: Line 7:
 
In [[class-based programming]], methods are defined in a class, and objects are instances of a given class. One of the most important capabilities that a method provides is method overriding. The same name (e.g., area) can be used for multiple different kinds of classes. This allows the sending objects to invoke behaviors and to delegate the implementation of those behaviors to the receiving object.
 
In [[class-based programming]], methods are defined in a class, and objects are instances of a given class. One of the most important capabilities that a method provides is method overriding. The same name (e.g., area) can be used for multiple different kinds of classes. This allows the sending objects to invoke behaviors and to delegate the implementation of those behaviors to the receiving object.
  
Method in [[Java (programming langauge)]] programming sets the behavior of class object. For example, an object can send an area message to another object and the appropriate formula will be invoked whether the receiving object is a rectangle, circle, triangle, etc.
+
Method in [[Java (programming language)]] programming sets the behavior of class object. For example, an object can send an area message to another object and the appropriate formula will be invoked whether the receiving object is a rectangle, circle, triangle, etc.
  
Methods also provide the interface that other classes use to access and modify the data properties of an object. This is known as encapsulation. Encapsulation and overriding are the two primary distinguishing features between methods and procedure calls.
+
Methods also provide the interface that other classes use to access and modify the data properties of an object. This is known as encapsulation (see [[Data hiding]]). Encapsulation and overriding are the two primary distinguishing features between methods and procedure calls.
  
 
== See also ==
 
== See also ==

Revision as of 08:25, 4 September 2016

In object-oriented programming (OOP), a method (or message) is a procedure (see Subroutine) associated with an object.

Description

An object is made up of data and behavior, which form the interface that an object presents to the outside world. Data is represented as properties of the object and behavior as methods. For example, a Window object would have methods such as open and close, while its state (whether it is opened or closed) would be a property.

In class-based programming, methods are defined in a class, and objects are instances of a given class. One of the most important capabilities that a method provides is method overriding. The same name (e.g., area) can be used for multiple different kinds of classes. This allows the sending objects to invoke behaviors and to delegate the implementation of those behaviors to the receiving object.

Method in Java (programming language) programming sets the behavior of class object. For example, an object can send an area message to another object and the appropriate formula will be invoked whether the receiving object is a rectangle, circle, triangle, etc.

Methods also provide the interface that other classes use to access and modify the data properties of an object. This is known as encapsulation (see Data hiding). Encapsulation and overriding are the two primary distinguishing features between methods and procedure calls.

See also

External links

[[Category:]] [[Category:]]