<p>The actual class we are talking about is an instance of derived. Thus, calling b.methodOne() invokes methodOne of the derived class. The derived class calls the superclass's methodOne which prints A. Then the superclass methodOne calls methodTwo. methodTwo is declared for class Derived, so it calls methodTwo in Derived, which calls the superclass methodTwo which prints B. Then D is printed since program control reverts to the proper method in Derived. Then C is printed because program control reverts back to Derived's method one which prints C last.</p>
<p>because Strings and primitive types are passed by value to a method and not by reference like objects. Thus, any changes made to a string or integer remain only in the method and not outside of it unless the values are returned from function using a return statement.</p>
<p>just to make sure, for question #20: When the superclass methodOne(); calls methodTwo();, it calls the subclass method because the object being worked on is actually Derived right? so because of polymorphism, it chooses the methodTwo(); from derived right?</p>
<p>i was aware of that. on that question i was concentrating on how the String wouldn't be changed b/c Strings are Immutable. but yea i realized the variables x and y would be destroyed after the method call anyways. thx MUCHOS!</p>