Classes and Objects

Class (Programming)

A class is a template or blueprint. Represents all similar objects of a kind.

  • Each class has associated source code that defines attributes and methods.
Link to original

Object (Programming)

An object is an instance of a class / belongs to a particular class and has individual characteristics. Many distinct instances be created from a single class.

  • Method

    A method is a procedure on an object which can be invoked. A method may have parameters to pass additional information. All methods have return types / values, a method may return void if no information is being handed back to the caller.

    A method implements the behaviour of objects, they have a consistent structure of a header and a body.

    • The header describes:
      • The visibility to objects of other classes.
      • Whether the method returns a result.
      • The name of the method.
      • Whether the method takes parameters.
    • The body encloses the body’s statements.
    Link to original
  • Class Attribute

    An object also has attributes, which are values stored in **fields**.

    The class defines what fields an object has, but each object stores its own set.

    State

    The state is the set of values of all fields of an object.

    Link to original

    Link to original
  • Method Signature

    Method signature: Consists of the function prototype and any relevant types.

    Link to original
Link to original

Note: for overloading, signature cannot be duplicated but name can be re-used.

Method signature is the method name and parameter types of a method. add(int v)

Method header: /*comment*/ public void add(int v)

0 items under this folder.