• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

jdiscuss mock exam on overloading

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello folks,


question: An overloading method must have a diferent parameter list and same return type as that of the overloaded method.
answer: false
explanation: There is no restriction on the return type. If the parameters are different then the methods are totally different (other than the name) so their return types can be anything.


well... isn't it violate the rule of overloading if the return type is different?
so, is the answer "true"?
 
Ranch Hand
Posts: 366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aaron,
the answer they gave is correct....
what you are talking about is overrirding
in overloading return type doesnt matter as long as the variable list or order or number changes
Hope this helps
Sri
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no, it doesen't matter whether the return type is the same or different; when you are overloading, the parameters must be different.
if you are overriding the parameters must be the same and the return type must be the same.
 
Aaron Anders
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
uh, oh...
i'm confused the question with the rule "you can't overload with same signature but different on return type"
so, the answer provided is correct.
thanks for replying!
 
Your mother is a hamster and your father smells of tiny ads!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic