Disclaimer: I am teaching in Canada and therefore I am unfamiliar with the American AP CS A and AP CS P curricula that others may have talked about. In my school board at least, it is still very grey what exactly to teach in AP CS. Essentially this is a grade 12 course continuing from grade 11 (which taught variables, arrays, loops, functions and simple inheritance). The goal of AP as posed to regular is to focus more on OOP, specifically SOLID principles.

With that out of the way, here's the situation. I am teaching a summer course to high school students who want an enriched Computer Science course in order to succeed in University. This is the first time this course is offered during the summer (and my first time teaching this course). This week, I decided to go over some review of Java basics to gauge the overall knowledge of my class. Ironically enough, everyone seemed to know variables and access modifiers, but as I began going over some Inheritance, students became confused over static variables, static space and where variables were.

I drew out a simple memory model and showed where static, heap, stack and meta-space. I could already tell there were a lot of blank faces (okay, let's back track). I essentially explained that things declared in the static space are global to the project and belong to a class as posed to instances. However, surprise surprise, I spent majority of this week helping students with "non static variable cannot be referenced in a static context".

For the rest of the term, I am wondering if I should devote a week to thoroughly explaining what exactly the static keyword means, what static space is and the Java memory model, or continue with the material (as there is a lot to cover) and just try to stray away from involving static space and variables in my examples?

  • $\begingroup$ My favorite example of a static class member is an object counter which gets incremented in constructors. Maybe with one clear example of what 'static' is good for they will be less lost? This goes with my 'hook' concept: an example gives people something to relate to and remember, and then add on to later. But you have to start with one particular. $\endgroup$
    – user737
    Commented Jul 7, 2017 at 14:36
  • $\begingroup$ Perhaps a better place to get an answer for this is the APCS community board. There are lots of knowledgeable people there. $\endgroup$
    – Buffy
    Commented Jul 7, 2017 at 17:03
  • $\begingroup$ Why would topics for AP-A be a gray area? The course description pretty clearly lays out what topics to cover? $\endgroup$
    – Ryan Nutt
    Commented Jul 7, 2017 at 18:02
  • $\begingroup$ @RyanNutt Like i've said in the disclaimer, your reference is American and in Canada, Colleges are different from Universities. I'm just trying to gauge what other high school teachers are doing, instead of following an American description in a Canadian school. $\endgroup$
    – Kaneki
    Commented Jul 7, 2017 at 18:27
  • $\begingroup$ Please do not apologise (Disclaimer) for not being American; Just state where you are from. This is not Computer Science Educators USA. Everyone else please recognise that the internet is global, there will be people form all over the world her. So say “in the USA the …. says …” $\endgroup$ Commented Jul 8, 2017 at 7:13

2 Answers 2


Static is within the AP subset and is fair game for the examination. Oddly enough, the memory model of Java that operates here is not, so students could, hypothetically, memorize a series of arbitrary rules and be fine here.

If you think it seems silly to teach about static without at least giving a passing understanding of how memory works, then you and I are on the same page. However, in this instance, I provide a simplified (and terribly inefficient!) view of memory usage, because I don't want to delve too far down this rabbit hole in what is essentially an introductory class. (Especially because we haven't yet covered the all-important idea of passing this as a parameter.)

Here is a picture of the PowerPoint slide with the setup itself (sans animation). Also not seen is another slide that says, "Hey class, when can a lie serve the truth? ... Right now!")

my false model of static

There are more slides, and quite a bit of discussion. But in essence, this model allows me to ask discussion questions like:

  • Why are there 3 Doublers in memory?
  • Why is there only one count?
  • What did static actually accomplish?
  • What would happen if we called val++ from inside method(). Is there any reasonable way for Java to interpret this?
  • What would happen if we called count++ from inside doubleVal()? Is there any reasonable way for Java to interpret this?

Now, as for the situation you are in, it sounds like you've already devoted a lot of time to this. I would not spend a great deal more time on static. There is a lot in the exam, and static is not heavily tested. I might do one more quick attempt to try to clarify this idea, but then move on. There is, as you said, plenty else to do.

  • $\begingroup$ I like the slide and questions. If used together. $\endgroup$ Commented Jul 8, 2017 at 7:25

If one understands objects, fields, and variables, static fields should be easy to understand (e.g. as fields of a "class object"). And if one does not understand objects, one can not apply OOP or software design, which makes it very hard (maybe even impossible) to really understand that material.

Therefore, a solid and accurate understanding of objects, fields and variables seems worth investing into even at the price of covering less of the official curriculum.

I am however not sure the memory spaces of the JVM are the best tool to communicate this, because your students may not know what memory spaces are. After all, memory spaces are like objects in that they host variables, so if people are unaware that variables exist in a scope and are bound to its lifetime, naming that scope "memory space" rather than "object" won't help.

BTW, when Java programmers say "Memory Model", they often refer to the so named chapter in the Java Language Specification, which gives a formal mathematical model for memory as seen by concurrently executing threads. That would probably be too advanced for your course ;-)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.