CS239 - Spring 2005 - Lecture Notes
Review of Classes, Objects and References
- Class
- A blueprint of an object--the model that defines the variables and
methods an object of that class will contain when instantiated.
- Object
- An instance of a class. An encapsulated collection of data variables
and methods.
- Reference
- A variable that holds the address of an object.
- Instantiate
- The act of creating a new instance of a class or an object from a
class.
- Constructor
- The special method that is called when the new operation is executed.
- Default Constructor
- A constructor that takes no arguments. Classes with no defined
constructors have an assumed default constructor.
- Instance variable
- An attribute of an object.
- Class variable
- An attribute shared by all objects of the class.
- Method
- A named group of declarations and programming statements that can be
invoked when needed. A method is part of a class and operates on
objects of that class. (Note: Java documentation generally lumps method
and function into the single term method.)
- Function
- A named group of declarations and programming statements that can be
invoked when needed. A function is part of a class, but does not need
an object on which to operate.
- Formal parameter
- The variable in a method or function which receives its value from an
actual parameter passed to it in the method or function invokation.
- Actual parameter
- The value (variable, expression, constant, or literal) that is passed
to a formal parameter in the method or function invokation.
Examples of using classes - review of lab from Wednesday
NOTE: These examples use the tasks of the assignment as commenting. In
general, that amount of commenting is more than what you need to do for
inline comments.
JMUview.java
JMUedit.java
JMUlti.java
This code shows a good example of using command line arguments, as well as
making use of the short-circuiting of Java's && operator.
Argue.java
What's the difference between declaring a primitive type variable and
declaring a reference type variable?
StringPlay.java
Explore parameter passing with respect to objects.
Color139.java
12-01-2006 - 08:38