CCA Prep

Lesson 2.3Lesson 9 of 24

Classes and inheritance

Given a business requirement, apply fundamentals of class implementation to solve the business requirement.

Classes and inheritanceclass Child extendsParentconstructorcall super() before thismethodson Child.prototypestaticon the class, inheritedby subclasses#privateonly inside the classbodyget / setrun on read and onassignment

Key points

  1. 1A class is a function. Methods go on its prototype and are shared; fields are created on each instance.
  2. 2Static members belong to the class itself. Instances do not have them, but subclasses inherit them.
  3. 3Private fields start with #, can be read only inside the class body, and are not normal string keys.
  4. 4A derived constructor must call super() before it uses this. super.method() calls the parent version.
  5. 5Class declarations are not usable before their line, and class bodies always run in strict mode.
What the exam guide checks here

Objective wording from the exam guide (English).

  • 2.3.K1class syntax: constructor, methods, static members, getters and setters, private fields
  • 2.3.K2Inheritance with extends and super; classes as syntax over prototypes
  • 2.3.S1Choose the class code that meets a requirement

Lock it in

Answer scenario questions on this topic. Every option comes with an explanation.

Practise 2.3 · 12 questions