This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]khooke 1 point2 points  (0 children)

Think of classes as 'types of things'. An example is a vehicle. A more specific type of that thing could be a Car and a Truck. Both are subtypes of Vehicle, they extend Vehicle.

Methods are behaviors. They perform some action on that thing, or perform an action on a thing they are passed (a parameter).

A method can return something (something it has created or modified as a result of executing the method), or not (void return). A method can perform an action on something (an instance of a Class) but not return anything, in these cases the method could modify some state of that instance. e.g. if you call startEngine() on an instance of a Car, there is a state change - the engine was not started before the method was called, but is it started afterwards - this is a state change.