Java- Method Signature / Chapter -5 / OOP's Concept

1. In Java method signature consists of, methods names followed by arguments types.


     2. Return Type is not part of method signature in java.
    3.Compiler will use method signature to resolve method calls.

example:-
class Test
{
        public void m1(int i)
       {
             System.out.println(int  type arguments");
         }   
        public void m1(String s)
       {
             System.out.println(String type  arguments");
         }   
        public static void main(String [ ] args )
        {
               Test   t    =new  Test( );
               t.m1(10);
               t.m1("javabychetan");
        }
}

Output
: int type arguments 
              String type arguments
              
4.In a class two method with same signature not allowed, If we are  trying to do so than we will get compile time error.

example:-



No comments:

Post a Comment

Be the first to comment!

Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.

Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.

Regards,
JavaByChetan
Back To Home

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com