16. Inheritance Flashcards
What two steps are needed to delete an element in a partially filled array?
ss
What is UML short for?
ss
In the representation for a class, how are public items distinguished from private ones?
ss
What four values are used to generate a colour?
ss
If the relationship ‘A is a B’ is modelled by two classes A and B, which is the superclass and which is the subclass?
A is a subclass B is a superclass
How do we invoke the constructor of the superclass, and when?
ss
When do we invoke the constructor of the superclass implicitly?
ss
What kinds of method can be overridden? Can the new version have a different body? Different parameters? Different name?
ss
What simple errors is the @Override annotation protect us from?
ss
If an object is polymorphic, what does that mean? And how do we achieve it?
ss
In what sense might a method be dynamically bound? Which types of method have this feature?
ss
In what way does a subclass extend its superclass?
ss
How do we make a class abstract, and what can we not do with it when we have made it abstract?
ss
How do we define an abstract method, and when do we? In what sense do we not override an abstract method?
ss
What does it mean to make a method final, and how do we achieve it? What kinds of method can be made final? What about a final class?
ss
How do we create an extension of a class which has more state?
ss
How is the idea of adding more instance methods related to adding more object state?
ss
How do we determine if an object is an instance of a particular class?
ss
What is the essential difference between a class cast and primitive type cast?
ss
Which of the following models ‘is a’ and which models ‘has a’?
1. public class DieselTrain extends Train { }
- public class Train {
private Carriage[] carriages;
}
ss
When might we want to use an overridden method, and how do we?
ss
What is the purpose of constructor chaining?
ss
When do we invoke another constructor from the same class, and how?
ss
What exactly is a default constructor, and when do we get one?
ss
All classes, except Object, have something. What is that thing?
ss
What does this default Object: toString() produce?
ss
Assuming a point class defined as one might expect, what is the affect of the following code?
System.out.println(new Point(10, 20));
ss