Hey folks,

Need your help:)

Wanted to understand the concept of method overloading and overriding in Java, as explained in Q.7 here.

How do we identify a problem, to which we can apply the above concept?

First, those are two completely different concepts.

Overloading is a convenience thing. Use it when you have a method that could be used with different paameters, eg an internet thing that could use an IPV4 or IPV6 address. You could have two methods with slightly differenet names, but the code will be clearer if you have the same name but different parameter types. It's also useful when you have some optional parameters, eg waitFor(something) and waitFor(something, timeout).

Overriding happens when you have a sublass that needs a different implementation of a method from its superclass. When that is needed its usually obvious.

commented: Are there any sources where I can practice problems specifically related to these two concepts, to deepen my knowledge about it. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.