Skip to main content
CS Teaching Tips

Main navigation

  • Browse All Tips
  • Tags
  • 3D
  • About
  • Rate Tips
  • Tip Sheets

Remind students that variable assignment occurs in the order assignments are given. This avoids the misconception that changing one value affects other variables assigned before it.

Share Remind students that variable assignment occurs in the order assignments are given. This avoids the misconception that changing one value affects other variables assigned before it. with FacebookShare Remind students that variable assignment occurs in the order assignments are given. This avoids the misconception that changing one value affects other variables assigned before it. with Twitter
  • E.g.,
    count1 = 3;
    count2 = 2;
    sum = count2 + count1;
    count1 = 4;

    In this example, the value of sum is 5 because the variable sum has not been redefined or reassigned. The variable sum will retain its value of 5 until it is assigned another value.

More about this tip

Tags

  • Content Misconceptions
  • CS 1
  • Intro Programming
  • Programming Concepts
External Source

"Visual program simulation in introductory programming education" by Juha Sorva, from Appendix A: Misconception Catalogue

Other Tips By
Other Tips By Juha Sorva

Similar tips

Have students write many small, simple classes in Java to scaffold their learning of the basics of object-oriented programming.
Misconception: Students mistakenly believe comparison expressions use the same syntax in math, English, and logic.
Misconception: Students have difficulty understanding why a while(true) loop continues forever.
  • CSTT Facebook
  • CSTT Twitter

For more information or to report a bug, contact us at admin@csteachingtips.org. Built with Bootstrap. Footer Icons by Mohammed Alyousfi. Powered by Drupal.

Privacy Policy

  • National Science Foundation
  • Sage Fox Group
  • Harvey Mudd College