Shaun Conlon CS 211 Section 6 3/13/2003 Notes Topics for this week: -P1 comments -A4 questions -Big-Oh Notation * Note that I was filling in for Clifton this week * As I said in section, here is an explanation of how the answers are obtained for 4a. I will detail the first two numbers here. I leave it up to you to figure out the other five (they are very similar to the first two. Peter Flynn's section notes about inheritance are very useful for tracing out what happens when a constructor is called. You should also realize that static and dynamic binding occur even when methods are called in constructors. Value 1 (6): A r1 = new B(1); -> calls B(1) -> calls A() [automatic super() call] -> data initializers in A run -> calls print(x+2) in B [dynamic binding] = print(3+2) = print(5) -> System.out.println(5+1) -> 6 is printed Value 2 (7): -> now back in B, data initializers run -> x = this.x [first x refers to constructor parameter] = x = 3 -> calls print(x+3) in B [dynamic binding] = print(3+3) = print(6) -> System.out.println(6+1) -> 7 is printed As I said above, you can trace out the rest of the output values yourself. See my notes for 3/27/2003 for Big-Oh notation. Email me (sc235) with any questions.