Comp 202 winter 2011 final exam solutions:
1)a)No, can't use "this" inside a static method
b)No, because no return value in case of x == y
c)Yes, compiles
d)Note that intPower has a bug in it. If exponent is < 0 and base > 1, since it returns an int, it will always return 0
So the output is just 1 (gives one because of 10^0 = 1)
2)a)Does not compile because x is a pivate property
b)Yes, compiles. The output is
bacbc
c)10 (w is a shared static property)
d)3 (since doing new Beta() "resets" the amount by creating a new object
3) Note: for fall 2011, this question is not examinable
4)a)EXIT_CODE, args, fileExtension
b)fd, args, fileExtension
c)ex, f1, inputFile, outputFile, fileExtension
d)input, output, inputFile, outputFile, fileExtension
e)f1, inputFile, outputFile, fileExtension, f2, in, out, buf, len
5)The problem is that montrealCafe and moreChoices both contain a property of type ArrayList