CCEA A-Level Software Systems Development CL4
Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures
Exception Handling and Managing Input and Output
Testing an Object Oriented Application
Graphical User Interface Objects and Events
Multiple Forms and Linking to Files
Designing, Testing and Evaluating an Event Driven Application
Reasons for Systems Development and Systems Methodologies
Managing Projects
Testing Strategies
Database Concepts and Entity Relationship Modelling
Normalisation and Structured Query Language
Project Management and the Systems Approach in Practice
Defining Requirements and Documenting the Design
Building a Desktop Solution with a Database
Testing and Evaluating the Solution
Objects, Classes and Data Structures
Overriding methods and run-time polymorphism
- 3 things to know
- AS Unit 1
Overview
Method overriding and abstract method.
What you need to know
Answer each one before you reveal it.
What does the annotation @Override do in Java?
What name is given to choosing the method version from the object's actual class while the program runs?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What is method overriding?
Model answer
Method overriding is a subclass supplying its own version of a method it has inherited, keeping exactly the same name and parameter list so the new version replaces the old one for objects of that subclass.
- 2
What must match between an inherited method and the method that overrides it?
Model answer
An overriding method must have the same name and the same parameter list as the inherited one, and its return type must be the same type or a subtype of it.
- 3
What does the annotation @Override do in Java?
Model answer
The annotation @Override tells the compiler that the method is meant to replace an inherited one, so a mistyped name is reported as an error instead of quietly creating a brand new method.
- 4
What is polymorphism?
Model answer
Polymorphism is the ability of one method call to run different code according to the actual class of the object the call is made on.
- 5
A class Shape defines public double area() { return 0; }. A subclass Circle holds private double r = 2; and overrides area to return 3.14 * r * r. What does System.out.println(s.area()); print when s is declared as Shape s = new Circle(); ?
Model answer
The object is a Circle, so the Circle version of area runs and works out 3.14 multiplied by 2 and again by 2, giving 12.56, so the statement prints 12.56.
- 6
Explain what happens at run time when an overridden method is called through a base-class reference.
Model answer
The declared type of the reference decides which method names the compiler will allow, but the actual class of the object decides which version executes, so the subclass version is the one that runs.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
Every question in Objects, Classes and Data Structures, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.