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:
There are currently no approved compatible licenses.
IANAL, but it seems to me that you cannot sublicense CC content under the Apache license.