For example if I have code that contains parts of code rewritten from code found here or on Stack Overflow or other Creative-Commons licensed code, can my final code be licensed with an Apache License?
You should read and understand any license that you agree to. CC licenses, like CC-BY-SA-3.0, explicitly state:
You may Distribute or Publicly Perform an Adaptation only under the terms of: (i) this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible License.
There are currently no approved compatible licenses.
IANAL, but it seems to me that you cannot sublicense CC content under the Apache license.
No, the licenses are not compatible as already outlined in the replies and one of the main differences is that the Apache License grants the patent rights together with the code unlike CC licenses.