What is the difference between function overloading and function overriding, and how is polymorphism achieved in Java? Provide examples.