CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS J2EE JAVA DETAILS
Question :
What restrictions are placed on method overloading?
Category Java Interview Questions
Rating (3.9) By 36 users
Added on 10/13/2004
Views 3133
Rate it!
Answers:

Two methods may not have the same name and argument list but different return types.



In method overloading function name will be same but the argument count or type or order must vary. They can have different return type also.



Posted by: Santhosh Paul    

Contact Santhosh Paul Contact Santhosh Paul

The only restriction on method overloading is the signature of the method.The signature is the number, type, and order of the arguments passed to a method.Any number of methods which have the same name(unless overridden) cannot have the same signature,though they can have the same return types in the same scope.The compiler uses the signature to detect which overloaded method to refer when a overloaded method is called.If two methods have the same name and signature the compiler will throw an runtime error.



Posted by: Amit Rane    

Contact Amit Rane Contact Amit Rane

restrictions for method overloading:
1. method names should be the same.
2. signatures should be different
3. return type may or may not be same.



Posted by: vibha    

Contact vibha Contact vibha

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    What restrictions are placed on method overriding?
    View Answer
    What happens when a thread cannot acquire a lock on an object?
    View Answer
    What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
    View Answer
    What classes of exceptions may be caught by a catch clause?
    View Answer
    What is the purpose of finalization?
    View Answer
    What is synchronization and why is it important?
    View Answer
    What are synchronized methods and synchronized statements?
    View Answer
    What is the serialization?
    View Answer
    How to make a class or a bean serializable?
    View Answer
    How many methods in the Serializable interface?
    View Answer

    Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

    Notify me when better answer is posted!
    Email:

    View ALL Java Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions
    Page URL: http://www.coolinterview.com/interview/357/default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

    1.75
    Cache = 0 Seconds