4
Reply

Difference between overloading and overriding ?

Astha Jain

Astha Jain

May 25, 2012
4.2k
0

    Overloading means when we use same function name for different argument number or types.It is useful to achieve polymorphism. Overriding means when we reimplement a function of a super class in a sub class so that inside the sub class only new definition is used.It is used to implement inheritance and reusability.

    amritesh srivastava
    July 31, 2012
    1

    OverLoading: 1.It is evaluated at compiletime. 2.Within a same class only we can overload a method 3. No keyword is necessary. Overriding: 1.it is evaluated at runtime 2.within a class cant do overriding.Can override the superclass virtual method from subclass method with same method name 3.need override and virtual keyword

    Premkumar Selvarajan
    September 28, 2012
    0

    Method overriding is when a child class redefines the same method as a parent class, with the same parameters. For example, the standard Java class java.util.LinkedHashSet extends java.util.HashSet. The method add() is overridden in LinkedHashSet. If you have a variable that is of type HashSet, and you call its add() method, it will call the appropriate implementation of add(), based on whether it is a HashSet or a LinkedHashSet. This is called polymorphism. Method overloading is defining several methods in the same class, that accept different numbers and types of parameters. In this case, the actual method called is decided at compile-time, based on the number and types of arguments. For instance, the method System.out.println() is overloaded, so that you can pass ints as well as Strings, and it will call a different version of the method.

    rahul jaiswal
    August 24, 2012
    0

    Overloading is a compile time binding and overriding is a runtime or late binding.

    Akkiraju Ivaturi
    August 23, 2012
    0