IB Computer Science HL · Year 2 · Lesson 12

Static/instance members, constructors and object creation

Object-oriented programming models a problem through classes and objects, with clear responsibilities and controlled access to state.

Paper 250 minutesB3.1.3 · B3.1.4
Today’s targets

What you need to be able to do

2 / 8
  • DistinguishBetween static and non-static variables and methods
  • ConstructCode to define classes and instantiate objects
B3.1.3B3.1.4
Paper 2 lensMatch the depth of every response to the command term. Previously learned content can move quickly, but retrieval must still be accurate.
Retrieve

Rapid Recall Deck

3 / 8

Say the answer aloud before flipping. Mark secure knowledge quickly and spend time on the gaps.

  • What is an instance variable?: A variable whose value belongs to a particular object, so different objects can hold different values.
  • What is a static or class variable?: A variable associated with the class itself and shared rather than separately stored for each object.
  • When should an instance variable be preferred to a class variable?: When the value represents state that can differ from one object to another.
  • What is a constructor used for?: It initializes a newly created object's state by assigning its initial attribute values.
  • What does it mean to instantiate an object?: To create a concrete object from a class definition, usually by calling the class constructor.
B3.1.3 + B3.1.4 · Learn

Core knowledge and application

4 / 8
B3.1.3Distinguish

Between static and non-static variables and methods

Object-oriented programming models a problem through classes and objects, with clear responsibilities and controlled access to state.

Exam moveMake the differences clear with precise contrasting features.
Required detail 1Compare static and non-static variables and methods, including their usage and scope
Required detail 2When to use instance variables instead of class variables, and how to apply these concepts effectively in code
Assessment boundaryPaper 2

Explain it without notes

Distinguish: Between static and non-static variables and methods in the context of a library-management application.

  • Compare static and non-static variables and methods, including their usage and scope
  • When to use instance variables instead of class variables, and how to apply these concepts effectively in code
B3.1.4Construct

Code to define classes and instantiate objects

Object-oriented programming models a problem through classes and objects, with clear responsibilities and controlled access to state.

Exam moveProduce the required code, diagram, query, model or representation accurately.
Required detail 1How to define classes and create objects from those classes
Required detail 2Role of constructors in initializing an object's state, setting initial values for its attributes to define its condition or characteristics at the time of creation
Assessment boundaryPaper 2

Explain it without notes

Construct: Code to define classes and instantiate objects in the context of a library-management application.

  • How to define classes and create objects from those classes
  • Role of constructors in initializing an object's state, setting initial values for its attributes to define its condition or characteristics at the time of creation
Worked example · B3.1.3 / B3.1.4

Static vs instance state, constructors and objects

5 / 8
class Book:
    library_name = "Central Library"   # class/static-style data

    def __init__(self, title):
        self.title = title             # instance data
        self.on_loan = False

b1 = Book("Dune")
b2 = Book("Neuromancer")
b1.on_loan = True
DistinguishWhich value is shared by all objects? Which values belong to individual objects? What state does the constructor establish at creation time?
Apply

Transfer to a new scenario

6 / 8
ScenarioA library-management application needs a design or technical decision related to today’s topic. Explain what matters and why.
  • Compare static and non-static variables and methods, including their usage and scope
  • When to use instance variables instead of class variables, and how to apply these concepts effectively in code
  • How to define classes and create objects from those classes
  • Role of constructors in initializing an object's state, setting initial values for its attributes to define its condition or characteristics at the time of creation
Exam lens

Paper 2 practice

7 / 8
Build the response before checking notesUse precise terminology and match the required depth.
  1. Distinguish: Between static and non-static variables and methods in the context of a library-management application.
  2. Construct: Code to define classes and instantiate objects in the context of a library-management application.
Self-checkAnswer the exact command term. For explain, include mechanism/reason; for compare, pair criteria; for discuss/evaluate/justify, build supported reasoning and a conclusion.
Homework

Finish the learning cycle

8 / 8

IA — main task

Continue Criterion D development. Keep code readable, record meaningful implementation decisions, and maintain testing/evidence notes as you work.

Syllabus — short

Complete one targeted Paper 2/Paper 1 retrieval task from today’s lesson.