0

I'm struggling to know why method overloading and overriding needed in java?

I have read some articles regarding this but not able to catch why it's needed practically? i realize after so much searching that suppose we want to load a truck with many types of vegetables(potato and tomato). our simply target is to load these in truck.now there is two way for loads these vegetables in truck. 1. one 'बोरी(sack) we full it by potato and in other we full it by tomato. 2. in one sack we can full it by tomato & potato both and in 2nd sack we can full it by also potato & tomato. in both condition we are just load vegetables. if vegetables are larger in the compare of truck's loading capacity then all knows that we use one more truck for loading rest of vegetables. In whole time our target is just load these vegetables either it will come in one truck or more than one truck. so how we can say that this is overloading. Because on every sites of google and in every videos(example : watch video from 0:12 in given link below) everywhere overloading means to overload anything. So my question is why overloading needed and according to my example what is difference between in overloading or loading?

https://www.youtube.com/watch?v=oPReVfof9Ws

Vicky
  • 1,135
  • 1
  • 17
  • 37

1 Answers1

0

Let me try to clear your confusion. In general terms Overload means : too much of something but in terms of java if you are declaring same thing more then once it is called overloading. so do not get confused between term overloading and overloading in java. Like you can declare same method(method with same name but different arguments) more then once in a particular class then it is called method overlading.

Now between loading vs overloading in a general term : if you are putting some items(x,y,z) some where that means you are increasing load on that place. But if you are putting the items in excess that means you are overloading that place with those items.

And for why we need overloading in java, you can refer : Why is method overloading and overriding needed in java?

Vicky
  • 1,135
  • 1
  • 17
  • 37