Andres Object, Method, Constructor, and General Java Reference Sheet

By Katie Diaz,2014-04-24 12:42
10 views 0
Andres Object, Method, Constructor, and General Java Reference Sheet

    Andre‚Äôs Object, Method, Constructor, and General Java

    Reference Sheet


    - A CLASS is the model, pattern, or blueprint from which an OBJECT is created.

    - You can use one CLASS to create several OBJECTs just as you can use a blueprint to

    create several independent, yet structurally identical, houses.

    - Contains declarations of the data that will be stored in each object & the declarations of the methods that can be invoked using an object


    - An OBJECT is an instance of a CLASS

    - The OBJECT is created by the CLASS

    - Multiple OBJECTs can be created by a single CLASS, making them all identical in

    form but independent in nature

    - Get instantiated using lines like: Object objectname = new Object (parameters);

    - Should be self-governing: in other words, variables contained in OBJECT should only

    be altered within the OBJECT

    - Only METHODs within an object should have access to variables in that object


    - A named group of declarations & programming statements that can be invoked when


    - Take the form: visibility type NAME ()


     operations & lines of code which can be anything really


    - Example: public void flip ()


     face = (int) (Math.random() * 2);


    - Header of a METHOD includes: return value, method name, list of parameters


    - A special METHOD that uses the same name as the CLASS

    - Invoked when an OBJECT is instantiated from the CLASS; used to initialize the


    - Takes the form: visibility NAME (parameters)


     operations (parameters);


    - Example: public Coin ()


     flip ();


    Instance Variables/Data - A variable that must be referenced through a particular instance of a class, instead of to

    a class variable

    - Memory space is created for each instance of the class that is created

    - Example: A class can create a coin variable, and if that class is called 1000 times,

    you will have 1000 identical yet separate coins. - This is declared within a CLASS, but no particular METHOD

    - When declared at the CLASS level, has a scope of the entire CLASS, with any

    METHOD therein

Local Data

    - Data that is limited to only the METHOD in which it is declared

    Visibility Modifier - Reserved words in Java that control access to members of a CLASS

    - private, public, protected are the 3 modifiers

    - private means that a member of a CLASS can be used anywhere within that private

    CLASS but nowhere else

    - public means that a member of a CLASS can be used anywhere in or outside of the


    - protected only matters when dealing with inheritance

    - INSTANCE DATA should be defined with private visibility

Report this document

For any questions or suggestions please email