levo

Fundamentals of Programming

Classes, Objects, Inheritance and Polymorphism

  • 3 things to know
  • Paper 1
Start revising · £5/month

Overview

Recall questions on classes, objects and instantiation, constructors, attributes and methods, encapsulation with getters and setters, inheritance and when to use it, overriding, and polymorphism.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Evaluation

Explain the advantages of the structured approach.

Key term

What is the difference between an attribute (property field) and a method?

Key term

What does a subclass inherit, and what can it do that its superclass cannot?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is a class?

    Model answer

    A template or blueprint that defines the methods and the property or attribute fields capturing the common behaviours and characteristics of a group of objects. It describes what any object of that kind will have and be able to do, but is not itself one of those objects. A class also acts as a data type, so variables can be declared of that class type.

  2. 2

    What is an object?

    Model answer

    A particular instance of a class, existing in memory while the program runs, with its own values in the attribute fields the class defines and able to carry out the methods the class defines. Many objects can be created from one class, each holding its own data.

  3. 3

    Distinguish between a class and an object, with an example.

    Model answer

    The class is the definition; the object is a thing made from it. A class Car might define attributes registration, make and mileage and methods start and service; the individual car with registration AB12 CDE is an object of that class. Changing that object's mileage affects only that object, whereas changing the class definition affects every object created from it. One class, any number of objects.

  4. 4

    What is instantiation?

    Model answer

    The process of creating an object from a class. Memory is allocated for the new object, a constructor is run to set up its initial attribute values, and a reference to the object is assigned to a reference variable of the class type, through which the object is then used.

  5. 5

    What is a constructor, and what is meant by an implicit and an explicit one?

    Model answer

    A constructor is the special method run automatically when an object is instantiated, whose job is to put the new object into a valid initial state. An explicit constructor is one the programmer writes, typically taking parameters so that initial attribute values can be supplied at creation. An implicit constructor is the default one the language supplies when none has been written, which creates the object with default attribute values.

  6. 6

    What is the difference between an attribute (property field) and a method?

    Model answer

    An attribute is a data item belonging to an object, describing a characteristic of it, such as a car's mileage. A method is a subroutine belonging to the class, defining a behaviour the object can perform, such as service, and it can read and change that object's attributes. A class definition consists of both.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A driver is .
softwarehardwarestorage

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

Head means the first single element of a non-empty list.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Fundamentals of Programming, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.