Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is that Overload or Override?

Tags:

java

public class overload1 {
    public Object show()
    {
        return "0";

    }

}
class overload2 extends overload1{
    public String show(){
        return "1";
    }
}
like image 906
Abhisek Avatar asked May 06 '11 07:05

Abhisek


1 Answers

Override. You are extending the class, and overriding the superclass method.

Overload would look like this:

public class overload1 {
    public Object show()
    {
        return "0";
    }
    public Object show(Object arg)  // Same method name, but different arguments.
    {
        return "0";
    }
}
like image 90
Tom Jefferys Avatar answered Oct 05 '22 08:10

Tom Jefferys