Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Polymorphism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Polymorphism" Watch "Polymorphism" New topic


Lisa Wilson

Joined: Jul 20, 2005
Posts: 2
I am just beginning to learn Java.Can someone please tell me the difference between overloadind and over riding?.
Jared White

Joined: Aug 11, 2004
Posts: 7
Overloading is giving a method a new signature.

public int add( int i, int j)
public int add( int i, int j, int k)

Both of these methods have the same name "add" but since the parameters are different the add method is now overloaded.

A method is overridden when you redefine a method in a subclass that was previously defined in a superclass.


public class A{

//returns the correct sum of i + j
public int add(int i, int j){
return i+j;

public class BadA{

//returns the incorrect sum of i + j
public int add(int i, int j){
return i+j+1;

The add method in class BadA overrides the add method of class A.

I hope this helps.
Richard Anderson
Ranch Hand

Joined: May 20, 2005
Posts: 61
Difference between Overloading and Overriding

-Rich, SCJP 1.4
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it


Thanks! and welcome to the JavaRanch!


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Lisa Wilson

Joined: Jul 20, 2005
Posts: 2
Thanks Jared and Richard
I agree. Here's the link:
subject: Polymorphism
It's not a secret anymore!