what is mean by method signature?

Answer Posted / vikneswarank

method signature means defind the method in diff signature
diff no arguments
diff datatype if arguments
diff sequence of arguments
for example

public class PolyOverload1
{
public int iEmpNo;
protected double dbSalary;
private boolean boolPermanent;
String strEmpName;

public PolyOverload1()
{
System.out.println("PolyOverload constructor");
iEmpNo = 1001;
strEmpName = "Base Employee";
dbSalary = 20000.500;
}

public void getEmpDetails()
{
// to print the employee details
System.out.println("Emp no : " + iEmpNo);
System.out.println("Emp name : " + strEmpName);
}

//no of arguments difference
public void getEmpDetails(int eno)
{
//to print the employee details
System.out.println("Emp no [getEmpDetails(int eno)]
: " + eno);
System.out.println("Emp name [getEmpDetails(int
eno)] : " + strEmpName);
}

//different type of data type
//note : return type can be different for overloading
public int getEmpDetails(String ename)
{
// to print the employee details
System.out.println("Emp no [getEmpDetails(String
ename)] : " + iEmpNo);
System.out.println("Emp name [getEmpDetails(String
ename)] : " + ename);
return iEmpNo;
}

//no of arguments difference
public void getEmpDetails(int eno, String ename)
{
// to print the employee details
System.out.println("Emp no [getEmpDetails(int eno,
String ename)] : " + eno);
System.out.println("Emp name [getEmpDetails(int eno,
String ename)] : " + ename);
}

//different seguence type of data type
public void getEmpDetails(String ename, int eno)
{
// to print the employee details
System.out.println("Emp no [getEmpDetails(String
ename, String eno)] : " + eno);
System.out.println("Emp name [getEmpDetails(String
ename, String eno)] : " + ename);
}

public static void main (String arg[])
{
//Object creation
PolyOverload1 polyObj = new PolyOverload1();
//static binding or early binding...during compile
time JVM will find that the method's reference to call
polyObj.getEmpDetails();
polyObj.getEmpDetails(1002);
polyObj.getEmpDetails("Test Employee1");
polyObj.getEmpDetails(1003, "Test Employee2");
polyObj.getEmpDetails("Test Employee3", 1004);
}
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Name container classes in java programming?

591


What are the advantages of defining packages in java?

504


If an object reference is set to null, will the garbage collector immediately free the memory held by that object?

633


What is method overloading in JAVA? Why is it not present in C ?

586


Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx

1601






What is double parsedouble in java?

538


You're given a Boolean 2D matrix, can you find the number of islands?

591


How to sort numbers in java without array?

525


What is the difference between a method and a procedure?

541


What are the disadvantages of using inner classes?

549


How can we pass argument to a function by reference instead of pass by value?

580


What is the super void?

454


What is temp in java?

547


Can a class have multiple constructors?

531


Explain differences between collection api and stream api?

608