public class Car { public static void main (String [] args) { Car a = new Car(); Car b = new Ferrari(); //Car ref, but a Ferrari object a.start(); // Runs the Car version of start() b.start(); // Runs the Ferrari version of start() } } class Car { public void start() { System.out.println("This is a Generic start to any Car"); } } class Ferrari extends Car { public void start() { System.out.println("Lets start the Ferrari and go out for a cool Party."); } } |
All about studying for a Java interview in the Financial and trading services industry. I am a software engineer working with trading systems. 20 years experience coding and all things IT.
Sunday, June 15, 2014
What is Function Over-Riding and Over-Loading in Java?
Snippet below should explain things better.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment