• Post Reply Bookmark Topic Watch Topic
  • New Topic

Could some one give me practise questions on method overloading  RSS feed

 
midhun raj
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could some one please give me about 15-20 practical questions on method overloading.I have to make my cousine the concept clear by making him do more sample practise problem.Any help would be highly appreciated
 
Rajdeep Biswas
Ranch Hand
Posts: 231
1
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It will be great if you specify what do you understand by method overloading when you say "method overloading".
 
midhun raj
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In java method overloading means functions with same function signature but different return type and differ in the amount of there argument...
I need questions like this for example...


Write a program on function overloading with aera() of cube,cuboid,sphere etc...

please share some more example questions of this sort
 
Kacper Szmigiel
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I will write some code for you.



Constructor of class example is overloaded. Now, draw a conclusion by yourself
 
Rajdeep Biswas
Ranch Hand
Posts: 231
1
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
midhun raj wrote:In java method overloading means functions with same function signature but different return type and differ in the amount of there argument...

Yes, you are correct. Just think overloading as a concept known only to us. The compiler and JVM thinks of them as totally different methods (they consider only the whole prototype to judge similarity of methods), and for us, just their names are common.
So we use overloading when we feel that we are performing similar tasks but for different arguments or any other parameters.

For example, take an addition method.



So depending upon your thought-space, you can construct as many overloaded methods you want!
Hope that helps.
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the parameter types are part of the signature, so overloaded methods must have different signatures. They have the same method identifier.
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And overloaded methods might have the same return type
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!