It'll work because Math.pow is pow(double a, double b):
Math (Java Platform SE 6)
'n + 2' is an expression whose value is int if n is an int and double if n is a double (the '2' is an int and would be 'promoted' to double if n is double so that double+double=double can be computed). 5 is an int, so the Java compiler will perform a 'widening primitive conversion' on 5 (and on the result of n + 2, if needed) so that the method invocation matches the Math.pow method signature:
Conversions and Promotions