Skip to content

Career guides / Learning worksheets

Inheritance and super in Java

Inheritance lets a class extend another class's behavior. The super keyword can refer to superclass behavior or constructors; use inheritance only for a meaningful subtype relationship.

Before you begin

Be comfortable with variables, conditions, loops and basic methods. Use a small local project with a recorded JDK version and keep the input data fictional.

Work through the idea

Write the expected behavior before implementing the exercise. Keep the first version small enough to trace manually, then change one input or requirement. Record both the successful path and an invalid or empty-input case so that the result demonstrates reasoning rather than a copied output.

  1. Identify inherited and overridden behavior
  2. Trace constructor calls
  3. Compare composition with inheritance

Practice task

Model a basic notification class and a specialized email notification in a small exercise.

Check your result

Explain which method is selected when the object is referenced through the parent type.

A mistake to avoid

Do not use inheritance merely to avoid copying unrelated fields.

Keep a review note

Save the inputs or scenario, your reasoning and the result you checked. Explain one assumption and one case that needs more work. Revise the exercise after feedback and distinguish what you demonstrated from what remains untested.

Official reference for further study

Explore the related learning path · Choose another worksheet