Computer Science · B3.1 Fundamentals of OOP for a Single Class

B3.1.3 — Static vs Non-Static Variables and Methods

Preview

IB DP Computer Science — B3 Object-oriented programming — Fundamentals of OOP for a single class | SL | B3.1.3

📋 What You Will Learn

  • Distinguish static (class) members from non-static (instance) members by ownership, scope and lifetime
  • Explain why every object shares one copy of a static variable but owns its own instance variables
  • Construct classes using static and non-static members correctly in Java and Python
  • Trace code that mixes shared and per-object state
  • Decide, for a given requirement, whether a variable or method should be static

🏫 Why This Matters In a school, every student has their own locker (per-student state), but there is exactly one bell schedule on the wall that all students share. Change the bell schedule and everyone is affected; change one locker's contents and only that student notices. Instance variables are lockers; static variables are the bell schedule.

The Core Distinction

📖 Definition — Static and non-static members

  • Static (class)

Continue reading the full note