Object Reference

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

Are a business card, your name, and the actual you different things? — Yes

Are a variable, a reference, and an object different things? — Yes

Object Reference

An object is constructed out a chunk of main memory and hence has a unique location. An object reference describes the location in memory of a particular object. In the picture, the variable str contains a reference to the object.

Objects are created while a program is running. When an object reference is assigned to a variable, then that variable says how to find that object in memory.

In diagrams, an object reference is shown as an arrow from the object reference variable to the object. (An object reference is actually a complicated bit pattern.)

QUESTION 6:

What does a variable of a primitive type contain?