What are the 9 forms of inheritance?

What is specialization?

What is specification?

What is construction?

What is generalization?

What is extension?

What is limitation?
Behaviour of subclass is smaller or more restrictive than parent (excludes some operations)

What is containment?

What is variance?

What is combination?

What does the stack frames look like for (instance of B is a subclass of A):

Pointer-based objects (C++/Java) - someA is a pointer-to-A, someB is a pointer-to-B. Draw the the stack frame of what happens when we make someA point to a B instance.


In Stack-Based or Static Objects (C++ only), what happens if we try someA = SomeB?


For Stack-Based or Static objects(C++ only)
What happens if we try to make someB = someA?

In the following code, what does the following code snippets do?:


What does the following code output?


In the following code what do the following lines of code mean?:


What is the output of the following code?:


In general, what are the 4 things subclasses can do?

What is the difference between replacement and inheritance?
Inheritance: If a subclass recieves a message for which it has no definition, the message is passed to the superclass.
Replacement (see below):

What is Shadowing?
For the following classes, what does the attached code print and what is happening?
class Parent {
public int x = 12;
public void doIt( ) { System.out.println(“In Parent!”);}
}
class Child extends Parent{
public int x = 6;
public void doIt( ) { System.out.println(“In Child!”);}
}

Data members are shadowed: Child’s x shadows the parent’s x. Can bypass child’s shadowing data by referring to object throught he parent type. Done at compile time - compiler “knows” which x to refer to by pointer type being used.
p.doIt( ) still prints “in child” because it’s polymorphic, java is always looking at the dynamic type (the variable’s data) and routing the message there - you can’t turn this off!

What does the following code do and why?
If we made the methods virtual, would they be polymorphic?


How do you force or forbid overriding?