levo

Objects, Classes and Data Structures

Inheritance and the base class

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

Overview

Deriving one class from another, what a subclass inherits and what it does not, calling the base constructor, overriding a method, and the is-a test for deciding whether inheritance is the right relationship.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Which Java keyword sets up inheritance?

Key term

Give the alternative names for the two classes in an inheritance relationship.

Key term

Which members of a base class does a subclass inherit, and which does it not?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is inheritance?

    Model answer

    Inheritance lets a new class take on the attributes and methods of an existing class and then add to or change what it needs, so shared code is written once and used many times.

  2. 2

    Which Java keyword sets up inheritance?

    Model answer

    Java writes inheritance with the keyword extends, as in class Manager extends Employee.

  3. 3

    Give the alternative names for the two classes in an inheritance relationship.

    Model answer

    The class being inherited from is called the base class, superclass or parent class, and the class inheriting from it is the derived class, subclass or child class.

  4. 4

    Which members of a base class does a subclass inherit, and which does it not?

    Model answer

    A subclass inherits the public and protected attributes and methods of its base class; constructors are not inherited, and private members exist in the object but cannot be named by the subclass.

  5. 5

    A class Employee holds name and pay, and Manager extends Employee and adds budget. What does one Manager object hold?

    Model answer

    A Manager object holds name, pay and budget together, because the object carries the base class attributes as well as those the subclass declares.

  6. 6

    What is the is-a test?

    Model answer

    The is-a test asks whether every object of the proposed subclass is genuinely a kind of the base class, and inheritance is only appropriate when the answer is yes.

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.

Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures

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 null is the of one.
absencepresencetype

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.

An error is the mistake a person made.
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 Objects, Classes and Data Structures, 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.