All right, let's talk about assessment options for inheritance, and I think I said this back when we were doing Unit 5 with classes. I feel a lot of inheritance questions tend to fall into the category of just do you know the rules, do you know the exact nomenclature for extending that subclass? When you declare a superclass type object using the subclass constructor what happens? Not my personal favorite thing to ask on my exams, because again it's something you could look up very easily if you were actually out in the real world. I tend to test most of my inheritance things through programming problems. That said, because they're factual questions, they're not that hard to rate. So you could be seeing some of these as multiple choice questions. 9.1 really if you remember back that far, all we did was really introduced terminology, it was called "Why use inheritance" But really all we did is that you say, "Call it a subclass, call it a superclass." There's this word extends, so not much there. In writing constructors for subclasses, one of the more advanced things that you can do and basically everything from here on out is given two classes one is a subclass of the other which is a superclass. So given two classes, one which extends the other, identify an English description of what is executed when, and that way basically it's a form of tracing. But you're not saying exactly what the output, you're saying, "Tell me what methods got called in what order." With constructors in particular, the key things that you want to be looking at for some knowledge is if you call a constructor in the superclass, I'm sorry in the subclass, either with or without an explicit call to super, that there is going to be a call to super. If you don't explicitly call it, it's going to be the super no parameter constructor. But also it could be that a variable of the super class is instantiated within inside the subclass instructor and then you have to use the appropriate method for doing that. Overriding methods. Identify what class and object might be to show your knowledge of the following. We're going to see this for a while. So let me start over again because it's important to get the set-up right on this. So you're saying, here's an object, what class is it basically the superclass or the subclass.? But they want to tell you what it could be to show that the type that it's declared doesn't tell you that it might be instantiated as a subclass. So when we compile and we declare a variable to be of the superclass type, we could have instantiated it with the subclass type. We won't know until runtime. We do know because we look at it, but that's that weird thing about it's said in polymorphism, yeah, that. The super keyword not so difficult here giving us some sequence of instructions calling methods in a class and or a subclass. Show that you understand how super gets used, and also instance variable scoping that when you're in the subclass, you can't directly access the superclass instance variables. You have to use the methods to access them. Creating references and using inheritance hierarchies, again, really the same thing as 9.3, identify that a subclass object, it's actually the reverse of that, but anyway. A subclass object, so now you'd say, declare your object to be at the subclass instead of the superclass. You can't instantiate it with the superclass constructor, because the superclass constructor isn't going to initialize all of your instance variables. It's only getting the ones in the superclass. So you can legally declare a superclass type object and instantiate it with a subclass, but not vice versa. Polymorphism, we're really still talking about a lot of the same things. Again it gets back to this idea of what do we know at compile time, and then this. Even though we can see it in the code, well it doesn't happen until runtime because of the late binding that supports polymorphism. So first off, and we've asked this before, but this is just slightly a different way we just talked about with constructors before. It's a compiler error to call methods that only exist in the subclass on a variable of superclass type. That's true unless you construct it with the subclass constructor and you cast it. If you just construct it with the subclass constructor, it's because of that late binding thing is going to say, "Wait, this is a superclass type" It doesn't have one of those methods in it. But if you cast it you can force it. You're just saying, "I promise you it will be a subclass type." The other thing, a superclass object instantiated with the subclass constructor calling a method that both of them have, will use the one in the subclass even though it's of type superclass. If it was instantiated with a subclass constructor it's going to try to do the method that's furthest down the chain in that subclass when it's called, it's not going to do the one in the superclass. You probably need to redo all of these with a particular example of I don't know, book in dictionary or something, just because you started talking about subclass and superclass and it can be easy to get confused. Talking about the object superclass, identify a correct call to toString or equals. We've been doing that for a while, we've been calling toString and equals ship. So now we learned about the fact that they're inherited and they actually have a parameter that's an object. That said, unless you particularly ask about how do you write an equals method? If you just having to identify a call it's not that hard. So if you're scratching your head going, "This seems real easy." Yeah, it is, if that's all you want.