Question:

Java: Difference between method overloading and method overriding?

by  |  earlier

0 LIKES UnLike

Java: Difference between method overloading and method overriding?

 Tags:

   Report

2 ANSWERS


  1. method overloading means the same method name can be used with different argument lists

    : for example:

    class Tree {

    void info() {print("...");}

    void info(String s) { print("...");}

    }

    or void print(int i){...} and void print(String s){...}

    but overriding provides new behavior using the same method signatures.


  2. Overloading basically means using the same name or symbol for different, but similar operations.  Like using the + sign for both addition and appending strings.

    Overriding means to replace the operation performed by the name or symbol. Example would be I have defined a method called concat that originally just concatenated strings, but later I define a new version of concat that joins two objects instead.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.