Overloading is the implementation of two more methods in the same class with different parameters (or arguments).

Overriding is the implementation of two methods that have the same implementation but process differently.

For example, you want to run a pizza deal, you would make an override method for your order. If a person orders 1 pizza you would charge them one price. If they order two they may get 10% off.

//Returns £10, for example
Pizza.getPrice(Pepperoni);

//Returns £18, for example
Pizza.getPrice(Pepperoni, Pepperoni);

However, if you want to override this “getPrice method”, you could override this.

class SmallPizza extends Pizza{
....

public int getGetPrice(){
return 5;
}

}

By making a “subclass” extend the Super class (pizza) then we can override a method and return what we like. In this case, we have OVERRIDDEN the getPrice and made it return 5.

I hope this explains it simply for you!

Until next time Josh

 

Leave a Reply
You May Also Like

Java Encapsulation explained simply

In Java, and generally in Object-oriented programming, there’s this magical thing called…

CPA: I Quit CPA Content Locking for a Few Reasons

I first found out about CPA at a pretty young age. When I started pushing locked content monetized by CPAGrip. But there was always this feeling of wrong-doing when I pushed CPA.

5 Whitehat CPA Methods & Niches

After being asked to release some whitehat CPA methods recently, here’s a…

UserTesting.com Review with Paypal Payment Proof (Paid Testing)

This just a quick post to give you a little confidence that…