>


CS239 - 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 - From an intro lab from prior semesters.

JMUView.java
JMUedit.java

Which of these versions of JMUlti is best? Why?
JMUltiB.java

JMUlti7.java

JMUltiQ.java

JMUltiW.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


Department of Computer Science Nancy Harris Home Page  
01-14-2014 - 12:07