Programs and Memory

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   hear noise   go to next page

Answer:

The answer is in the picture below.

Programs and Memory

memory array with changed cell

 

The processor has written a byte of data at location 7. The old contents of that location are lost. Main memory now looks like the picture.

When a program is running, it has a section of memory for the data it is using. Locations in that section can be changed as many times as the program needs. For example, if a program is adding up a list of numbers, the sum will be kept in main memory (probably using several bytes.) As new numbers are added to the sum, it will change and main memory will have to be changed, too.

Other sections of main memory might not change at all while a program is running. For example, the instructions that make up a program do not (usually) change as a program is running. The instructions of a running program are located in main memory, so those locations will not change.

When you write a program in Java (or most other languages) you do not need to keep track of memory locations and their contents. Part of the purpose of a programming language is to do these things automatically.


 

QUESTION 10:

(Review Question:) Where are programs and data kept for long-term storage?