Examples for this class are available in previous class notes.

 

*************************************************

 

Members

            Members are any variable or method that belongs to a class.

 

Scope of Variables

            Class Scope, Method Scope, Block Scope

            Variables that are out of scope are said to be “Shadowed”

 

This

            Allows access to shadowed Class Scope Variables

 

Method Overloading

            Same name, different parameters.

 

Promotion Rules

            Primitive variables are automatically cast if the new type “does not lose

                        information”

            If casting down (float to int); must be explicitly cast: (int) myFloat

 

Packages

            Package Names reflect directory structures

            Packages provide scope for private classes

            Classes that share a package do not need import statements

 

Imports

            simple-type-import declaration: import java.util.Math;

            type-import-on-demand declaration: import java.util.*;

                        Imports only classes THAT ARE USED!

            The compiler by default imports: java.lang.*;

            An import statement is not required when a method is called with the fully

                        qualified name: java.util.Math.sin( x );

 

Constructors

            Default constructors are created when no constructor is implemented

            Constructors can take parameters

 

Final

            Final declares a constant.

            A “final” constant can only be initialized once.

            Final constants may be initialized within the constructor.

 

Access Modifiers (public and private)

            Provide a “Public interface”

            “Information Hiding” is used to hide inner details of implementation and for

                        validation of variables before setting.

           

Set and Get Methods

            Used for providing validation and feedback when setting variables.

            Classes based solely on set and get are called “Java Beans”