Sample questions to prepare for the final quiz 6. Explain in your own words one advantage of parametric polymorphism over inheritance polymorphism. That is, what's the difference between using a type parameter , and calling your variables (for example) "A x" instead of "Object x". 1. Write a pointcut to pick out attempts to access public variables of class A. 2. Assume that classes C and D both have a function void f(int). Write a pointcut that picks out calls to either function. Also capture the argument passed with the pointcut. 3. Given class: class B { private int x; pubilc B(int x0) { x=x0; } // constructor public int f(int n) { if (n<2) return 1; else return n*f(n-1); } public void g(int y) { System.out.println(x+f(y)); } } 3a. Write a pointcut that picks out the "execution" of the constructor of B. (when the constructor is called, the object doesn't exist yet). 3b. Write a pointcut that picks out the initial call to f (as opposed to recursive calls). 3c. The following pointcut and advice tries to change the parameter passed to g. Explain what's wrong with it the way it's written. DON'T JUST CORRECT IT; *EXPLAIN* WHY IT'S WRONG THE WAY IT IS! before(int y) : call(void B.g(int)) && args(y) { g(y+1); } (hint: there are three problems that need to be addressed). 4. Write a pointcut that picks out attempts to call g from within class A, capturing the argument passed, as well as the "this" and "target" objects. 5. Explain the difference between "withincode" and "cflow" pointcuts.